Пример #1
0
        public static void AddOrder(Domain.OrdersManager newOrder)
        {
            PizzaEntities db    = new PizzaEntities();
            var           order = ConvertOrderToEntity(newOrder);

            db.Orders.Add(order);
            db.SaveChanges();
        }
Пример #2
0
        public Response AddOrEditCustomer(CustomerDTO customerDTO)
        {
            PizzaEntities _entities = new PizzaEntities();
            Common        _common   = new Common();

            Response _response = new Response();

            _response.Status = false;

            if (!string.IsNullOrEmpty(customerDTO.CustormerUID))
            {
                _response.Message = "Customer information updation failed";
            }
            else
            {
                _response.Message = "Customer information creation failed.";
            }

            try
            {
                if (!string.IsNullOrEmpty(customerDTO.CustormerUID))
                {
                    customerDTO.Custormer_UID = Convert.ToInt32(_common.Decrypt(customerDTO.CustormerUID));
                }

                var CustomerData = _entities.Customers.Where(wde => wde.Custormer_UID == customerDTO.Custormer_UID).FirstOrDefault();

                if (CustomerData != null)
                {
                    CustomerData.PhoneNumber = customerDTO.PhoneNumber;
                    CustomerData.Address1    = customerDTO.Address1;
                    CustomerData.Address2    = customerDTO.Address2;
                    CustomerData.City        = customerDTO.City;
                    CustomerData.State       = customerDTO.State;
                    CustomerData.Zip         = customerDTO.Zip;
                    CustomerData.EmployeeID  = customerDTO.EmployeeID;
                    _entities.SaveChanges();
                    _response.Status  = true;
                    _response.Message = "Customer information Updated Successfully.";
                }
                else
                {
                    CustomerData                 = new Customer();
                    CustomerData.Name            = customerDTO.Name;
                    CustomerData.PhoneNumber     = customerDTO.PhoneNumber;
                    CustomerData.Address1        = customerDTO.Address1;
                    CustomerData.Address2        = customerDTO.Address2;
                    CustomerData.City            = customerDTO.City;
                    CustomerData.State           = customerDTO.State;
                    CustomerData.Zip             = customerDTO.Zip;
                    CustomerData.EmployeeID      = customerDTO.EmployeeID;
                    CustomerData.OriginalAddDate = DateTime.Now;
                    _entities.AddToCustomers(CustomerData);
                    _entities.SaveChanges();
                    _response.Status  = true;
                    _response.Message = "Customer information created Successfully.";
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(_response);
        }