Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.31 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated from a template.
  4. //
  5. // Manual changes to this file may cause unexpected behavior in your application.
  6. // Manual changes to this file will be overwritten if the code is regenerated.
  7. // </auto-generated>
  8. //------------------------------------------------------------------------------
  9.  
  10. using System;
  11. using System.Data.Objects;
  12. using System.Data.Objects.DataClasses;
  13. using System.Data.EntityClient;
  14. using System.ComponentModel;
  15. using System.Xml.Serialization;
  16. using System.Runtime.Serialization;
  17. using System.ComponentModel.DataAnnotations;
  18. using System.Web.Mvc;
  19.  
  20. [assembly: EdmSchemaAttribute()]
  21.  
  22. namespace TESTFYP1
  23. {
  24. public partial class User
  25. {
  26. public int UserID { get; set; }
  27. [Required(ErrorMessage = "Please provide username", AllowEmptyStrings = false)]
  28. public string Username { get; set; }
  29. [Required(ErrorMessage = "Please provide Password", AllowEmptyStrings = false)]
  30. [DataType(System.ComponentModel.DataAnnotations.DataType.Password)]
  31. [StringLength(50, MinimumLength = 8, ErrorMessage = "Password must be 8 char long.")]
  32. public string Password { get; set; }
  33. [Compare("Password", ErrorMessage = "Confirm password dose not match.")]
  34. [DataType(System.ComponentModel.DataAnnotations.DataType.Password)]
  35. public string ConfirmPassword { get; set; }
  36. [Required(ErrorMessage = "Please provide full name", AllowEmptyStrings = false)]
  37. public string FullName { get; set; }
  38.  
  39. [RegularExpression(@"^([0-9a-zA-Z]([+-_.][0-9a-zA-Z]+)*)+@(([0-9a-zA-Z][-w]*[0-9a-zA-Z]*.)+[a-zA-Z0-9]{2,3})$",
  40. ErrorMessage = "Please provide valid email id")]
  41. public string EmailID { get; set; }
  42. }
  43. #region Contexts
  44.  
  45. /// <summary>
  46. /// No Metadata Documentation available.
  47. /// </summary>
  48. public partial class MyDatabaseEntities : ObjectContext
  49. {
  50. #region Constructors
  51.  
  52. /// <summary>
  53. /// Initializes a new MyDatabaseEntities object using the connection string found in the 'MyDatabaseEntities' section of the application configuration file.
  54. /// </summary>
  55. public MyDatabaseEntities() : base("name=MyDatabaseEntities", "MyDatabaseEntities")
  56. {
  57. this.ContextOptions.LazyLoadingEnabled = true;
  58. OnContextCreated();
  59. }
  60.  
  61. /// <summary>
  62. /// Initialize a new MyDatabaseEntities object.
  63. /// </summary>
  64. public MyDatabaseEntities(string connectionString) : base(connectionString, "MyDatabaseEntities")
  65. {
  66. this.ContextOptions.LazyLoadingEnabled = true;
  67. OnContextCreated();
  68. }
  69.  
  70. /// <summary>
  71. /// Initialize a new MyDatabaseEntities object.
  72. /// </summary>
  73. public MyDatabaseEntities(EntityConnection connection) : base(connection, "MyDatabaseEntities")
  74. {
  75. this.ContextOptions.LazyLoadingEnabled = true;
  76. OnContextCreated();
  77. }
  78.  
  79. #endregion
  80.  
  81. #region Partial Methods
  82.  
  83. partial void OnContextCreated();
  84.  
  85. #endregion
  86.  
  87. #region ObjectSet Properties
  88.  
  89. /// <summary>
  90. /// No Metadata Documentation available.
  91. /// </summary>
  92. public ObjectSet<Table1> Table1
  93. {
  94. get
  95. {
  96. if ((_Table1 == null))
  97. {
  98. _Table1 = base.CreateObjectSet<Table1>("Table1");
  99. }
  100. return _Table1;
  101. }
  102. }
  103. private ObjectSet<Table1> _Table1;
  104.  
  105. #endregion
  106. #region AddTo Methods
  107.  
  108. /// <summary>
  109. /// Deprecated Method for adding a new object to the Table1 EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead.
  110. /// </summary>
  111. public void AddToTable1(Table1 table1)
  112. {
  113. base.AddObject("Table1", table1);
  114. }
  115.  
  116. #endregion
  117. }
  118.  
  119.  
  120. #endregion
  121.  
  122. #region Entities
  123.  
  124. /// <summary>
  125. /// No Metadata Documentation available.
  126. /// </summary>
  127. [EdmEntityTypeAttribute(NamespaceName="MyDatabaseModel", Name="Table1")]
  128. [Serializable()]
  129. [DataContractAttribute(IsReference=true)]
  130. public partial class Table1 : EntityObject
  131. {
  132. #region Factory Method
  133.  
  134. /// <summary>
  135. /// Create a new Table1 object.
  136. /// </summary>
  137. /// <param name="userID">Initial value of the UserID property.</param>
  138. /// <param name="username">Initial value of the Username property.</param>
  139. /// <param name="password">Initial value of the Password property.</param>
  140. /// <param name="fullName">Initial value of the FullName property.</param>
  141. public static Table1 CreateTable1(global::System.Int32 userID, global::System.String username, global::System.String password, global::System.String fullName)
  142. {
  143. Table1 table1 = new Table1();
  144. table1.UserID = userID;
  145. table1.Username = username;
  146. table1.Password = password;
  147. table1.FullName = fullName;
  148. return table1;
  149. }
  150.  
  151. #endregion
  152. #region Primitive Properties
  153.  
  154. /// <summary>
  155. /// No Metadata Documentation available.
  156. /// </summary>
  157. [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
  158. [DataMemberAttribute()]
  159. public global::System.Int32 UserID
  160. {
  161. get
  162. {
  163. return _UserID;
  164. }
  165. set
  166. {
  167. if (_UserID != value)
  168. {
  169. OnUserIDChanging(value);
  170. ReportPropertyChanging("UserID");
  171. _UserID = StructuralObject.SetValidValue(value);
  172. ReportPropertyChanged("UserID");
  173. OnUserIDChanged();
  174. }
  175. }
  176. }
  177. private global::System.Int32 _UserID;
  178. partial void OnUserIDChanging(global::System.Int32 value);
  179. partial void OnUserIDChanged();
  180.  
  181. /// <summary>
  182. /// No Metadata Documentation available.
  183. /// </summary>
  184. [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
  185. [DataMemberAttribute()]
  186. public global::System.String Username
  187. {
  188. get
  189. {
  190. return _Username;
  191. }
  192. set
  193. {
  194. OnUsernameChanging(value);
  195. ReportPropertyChanging("Username");
  196. _Username = StructuralObject.SetValidValue(value, false);
  197. ReportPropertyChanged("Username");
  198. OnUsernameChanged();
  199. }
  200. }
  201. private global::System.String _Username;
  202. partial void OnUsernameChanging(global::System.String value);
  203. partial void OnUsernameChanged();
  204.  
  205. /// <summary>
  206. /// No Metadata Documentation available.
  207. /// </summary>
  208. [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
  209. [DataMemberAttribute()]
  210. public global::System.String Password
  211. {
  212. get
  213. {
  214. return _Password;
  215. }
  216. set
  217. {
  218. OnPasswordChanging(value);
  219. ReportPropertyChanging("Password");
  220. _Password = StructuralObject.SetValidValue(value, false);
  221. ReportPropertyChanged("Password");
  222. OnPasswordChanged();
  223. }
  224. }
  225. private global::System.String _Password;
  226. partial void OnPasswordChanging(global::System.String value);
  227. partial void OnPasswordChanged();
  228.  
  229. /// <summary>
  230. /// No Metadata Documentation available.
  231. /// </summary>
  232. [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
  233. [DataMemberAttribute()]
  234. public global::System.String FullName
  235. {
  236. get
  237. {
  238. return _FullName;
  239. }
  240. set
  241. {
  242. OnFullNameChanging(value);
  243. ReportPropertyChanging("FullName");
  244. _FullName = StructuralObject.SetValidValue(value, false);
  245. ReportPropertyChanged("FullName");
  246. OnFullNameChanged();
  247. }
  248. }
  249. private global::System.String _FullName;
  250. partial void OnFullNameChanging(global::System.String value);
  251. partial void OnFullNameChanged();
  252.  
  253. #endregion
  254.  
  255. }
  256.  
  257. #endregion
  258.  
  259. }
  260.  
  261. using System;
  262. using System.Collections.Generic;
  263. using System.Linq;
  264. using System.Web;
  265. using System.Web.Mvc;
  266.  
  267. namespace TESTFYP1.Controllers
  268. {
  269. public class HomeController : Controller
  270. {
  271. //
  272. // GET: /Home/
  273.  
  274. public ActionResult Index()
  275. {
  276. return View();
  277. }
  278. [HttpPost]
  279. [ValidateAntiForgeryToken]
  280. public ActionResult Index(User U)
  281. {
  282. if (ModelState.IsValid)
  283. {
  284. using (MyDatabaseEntities dc = new MyDatabaseEntities())
  285. {
  286. dc.Users.Add(U); //Error i em telling
  287. dc.SaveChanges();
  288. ModelState.Clear();
  289. U = null;
  290. ViewBag.Message = "Successfully Registration Done";
  291. }
  292. }
  293. return View(U);
  294. }
  295. }
  296. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement