Exemplo n.º 1
0
 public void Insert(string firstName, string surname, string tell, string mobileNumber, string address, string userName, string password)
 {
     using (var context = new Model.DomainModel.DTO.EF.KubissEntities2())
     {
         try
         {
             Model.DomainModel.DTO.EF.Person ref_person = new DTO.EF.Person();
             ref_person.FirstName    = firstName;
             ref_person.Surname      = surname;
             ref_person.Tell         = tell;
             ref_person.MobileNumber = mobileNumber;
             ref_person.Address      = address;
             ref_person.UserName     = userName;
             ref_person.Password     = password;
             context.Person.Add(ref_person);
             context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }
Exemplo n.º 2
0
 public bool SignIn(string userName, string password)
 {
     using (var context = new Model.DomainModel.DTO.EF.KubissEntities2())
     {
         try
         {
             bool message;
             var  myUser = context.Person.FirstOrDefault(u => u.UserName == userName && u.Password == password);
             if (myUser != null)
             {
                 message = true;
             }
             else
             {
                 message = false;
             }
             return(message);
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }
Exemplo n.º 3
0
 public void Edit(int id, string productName, int unitPrice, int quantity, int price, int code, byte[] image)
 {
     using (var context = new Model.DomainModel.DTO.EF.KubissEntities2())
     {
         try
         {
             var q = context.Product.First(p => p.Id == id) as Model.DomainModel.DTO.EF.Product;
             if (q != null)
             {
                 q.ProductName = productName;
                 q.UnitPrice   = unitPrice;
                 q.Quantity    = quantity;
                 q.Price       = price;
                 q.Code        = code;
                 q.Image       = image;
                 context.Entry(q).CurrentValues.SetValues(context.Product);
                 context.SaveChanges();
             }
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }
Exemplo n.º 4
0
 public void Insert(string productName, int unitPrice, int quantity, int price, int code, byte[] image)
 {
     using (var context = new Model.DomainModel.DTO.EF.KubissEntities2())
     {
         try
         {
             Model.DomainModel.DTO.EF.Product ref_product = new DTO.EF.Product();
             ref_product.ProductName = productName;
             ref_product.UnitPrice   = unitPrice;
             ref_product.Quantity    = quantity;
             ref_product.Price       = price;
             ref_product.Code        = code;
             ref_product.Image       = image;
             context.Product.Add(ref_product);
             context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }
Exemplo n.º 5
0
 public void Delete(int id)
 {
     using (var context = new Model.DomainModel.DTO.EF.KubissEntities2())
     {
         try
         {
             var q = context.Product.First(p => p.Id == id) as Model.DomainModel.DTO.EF.Product;
             if (q != null)
             {
                 context.Product.Remove(q);
                 context.SaveChanges();
             }
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }
Exemplo n.º 6
0
 public List <Model.DomainModel.DTO.EF.Product> Select()
 {
     using (var context = new Model.DomainModel.DTO.EF.KubissEntities2())
     {
         try
         {
             var q = context.Product.ToList();
             return(q);
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             if (context != null)
             {
                 context.Dispose();
             }
         }
     }
 }