public Customer Signup(string fullname, string gender, string phone)
        {
            Customer customer = new Customer();

            customer.CustomerFullname = fullname;
            customer.CustomerGender   = gender;
            customer.CustomerPhone    = phone;
            customer.CustomerPassword = CreateMd5("123456");
            customer.RoleId           = 2;
            _context.Customers.Add(customer);
            _context.SaveChanges();
            return(_context.Customers.ToList().Last());
        }
Example #2
0
 public Product Create(Product product)
 {
     product.ProductId = 0;
     _context.Products.Add(product);
     _context.SaveChanges();
     return(_context.Products.ToList().Last());
 }
Example #3
0
        public Staff Create(Staff staff)
        {
            staff.StaffId = 0;

            if (staff.StaffPassword == "")
            {
                staff.StaffPassword = CreateMd5("123456");
            }
            else
            {
                staff.StaffPassword = CreateMd5(staff.StaffPassword);
            }

            _context.Staffs.Add(staff);
            _context.SaveChanges();

            return(_context.Staffs.ToList().Last());
        }
        public Invoice CreateInvoice(Invoice invoice, List <InvoiceDetail> details)
        {
            _context.Invoices.Add(invoice);
            _context.SaveChanges();

            var i = _context.Invoices.ToList().Last();

            details.ForEach(d =>
            {
                d.InvoiceId = i.InvoiceId;
                _context.InvoiceDetails.Add(d);
                _context.SaveChanges();

                new ManageProductService().InventoryDelivery(d.InvoiceDetailAmount, d.ProductId);
                _context.SaveChanges();
            });
            _context.SaveChanges();

            return(i);
        }