Example #1
0
 public void Update(string id, string title, string nationalCode, string firstName, string surname, string country,
                    DateTime dateOfBirth, string contactEmail, string mobilNumber,
                    string username, string password, string address)
 {
     using (var context = new Model.DomainModel.DTO.EF.OnlineShoppingEntities())
     {
         try
         {
             Model.DomainModel.DTO.EF.Person ref_Person = new DTO.EF.Person();
             ref_Person                      = context.Person.Find(System.Convert.ToInt32(id));
             ref_Person.Title                = title;
             ref_Person.NationalCode         = nationalCode;
             ref_Person.FirstName            = firstName;
             ref_Person.Surname              = surname;
             ref_Person.Country              = country;
             ref_Person.DateofBirth          = dateOfBirth;
             ref_Person.ContactEmail         = contactEmail;
             ref_Person.MobileNumber         = mobilNumber;
             ref_Person.Username             = username;
             ref_Person.Password             = password;
             ref_Person.Address              = address;
             context.Entry(ref_Person).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }
Example #2
0
 public void Delete(int rowid)
 {
     using (var context = new Model.DomainModel.DTO.EF.OnlineShoppingEntities())
     {
         try
         {
             Model.DomainModel.DTO.EF.Person ref_Person = new DTO.EF.Person();
             ref_Person = context.Person.Find(rowid);
             context.Person.Remove(ref_Person);
             context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }