コード例 #1
0
ファイル: OrdersRepository.cs プロジェクト: zackfactual/Pizza
        public static void AddOrder(Domain.OrdersManager newOrder)
        {
            PizzaEntities db    = new PizzaEntities();
            var           order = ConvertOrderToEntity(newOrder);

            db.Orders.Add(order);
            db.SaveChanges();
        }
コード例 #2
0
ファイル: CustomerDAL.cs プロジェクト: rakesh8012/pizza
        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);
        }