public CustomerResult Create(CustomerParam param)
        {
            Data.Entity.Customer entity = CustomerParamConverter.Convert(param, null);
            CustomerDao.Save(entity);

            return(CustomerResultConverter.Convert(entity));
        }
        public CustomerResult Find(long id)
        {
            Data.Entity.Customer entity = CustomerDao.Find(id);
            CustomerResult       result = CustomerResultConverter.Convert(entity);

            return(result);
        }
Example #3
0
        public Data.Entity.Customer Save(Data.Entity.Customer entity)
        {
            CustomerStorage.CustomerList.Add(entity);
            CustomerStorage.CustomerDictionary.Add(entity.Id, entity);

            return(entity);
        }
        static CustomerStorage()
        {
            Data.Entity.Customer Customer1 = new Data.Entity.Customer
            {
            };

            Data.Entity.Customer Customer2 = new Data.Entity.Customer
            {
            };

            Data.Entity.Customer Customer3 = new Data.Entity.Customer
            {
            };
            Data.Entity.Customer Customer4 = new Data.Entity.Customer
            {
            };
            Data.Entity.Customer Customer5 = new Data.Entity.Customer
            {
            };
            Data.Entity.Customer Customer6 = new Data.Entity.Customer
            {
            };
            Data.Entity.Customer Customer7 = new Data.Entity.Customer
            {
            };
            Data.Entity.Customer Customer8 = new Data.Entity.Customer
            {
            };
            Data.Entity.Customer Customer9 = new Data.Entity.Customer
            {
            };
            Data.Entity.Customer Customer10 = new Data.Entity.Customer
            {
            };

            CustomerList.Add(Customer1);
            CustomerList.Add(Customer2);
            CustomerList.Add(Customer3);
            CustomerList.Add(Customer4);
            CustomerList.Add(Customer5);
            CustomerList.Add(Customer6);
            CustomerList.Add(Customer7);
            CustomerList.Add(Customer8);
            CustomerList.Add(Customer9);
            CustomerList.Add(Customer10);

            CustomerDictionary.Add(Customer1.Id, Customer1);
            CustomerDictionary.Add(Customer2.Id, Customer2);
            CustomerDictionary.Add(Customer3.Id, Customer3);
            CustomerDictionary.Add(Customer4.Id, Customer4);
            CustomerDictionary.Add(Customer5.Id, Customer5);
            CustomerDictionary.Add(Customer6.Id, Customer6);
            CustomerDictionary.Add(Customer7.Id, Customer7);
            CustomerDictionary.Add(Customer8.Id, Customer8);
            CustomerDictionary.Add(Customer9.Id, Customer9);
            CustomerDictionary.Add(Customer10.Id, Customer10);
        }
        public void Update(List <CustomerParam> param)
        {
            List <Data.Entity.Customer> entity = new List <Data.Entity.Customer>();

            foreach (var item in param)
            {
                Data.Entity.Customer oldEntity = CustomerDao.Find(item.Id);
                Data.Entity.Customer newEntity = CustomerParamConverter.Convert(item, null);
                CustomerDao.Update(newEntity);
            }
        }
        public CustomerResult Convert(Data.Entity.Customer param)
        {
            CustomerResult result = new CustomerResult()
            {
                Code               = param.Code,
                Id                 = param.Id,
                Description        = param.Description,
                Name               = param.Name,
                CustomerStatusId   = param.CustomerStatus.Id,
                CustomerStatusName = param.CustomerStatus.Name
            };

            return(result);
        }
        public Data.Entity.Customer Convert(CustomerParam param, Data.Entity.Customer oldentity)
        {
            Data.Entity.Customer entity = null;

            if (oldentity != null)
            {
                entity = oldentity;
            }
            else
            {
                entity = new Data.Entity.Customer
                {
                    Code        = param.Code,
                    Id          = param.Id,
                    Description = param.Description,
                    Name        = param.Name
                };
            }

            entity.CustomerStatus = CustomerStatusDao.Find(param.CustomerStatusId);

            return(entity);
        }
        public ActionResult Add(Models.Customer.AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Data.Entity.Customer customer = new Data.Entity.Customer();
            customer.TC       = model.TC;
            customer.Name     = model.Name;
            customer.LastName = model.LastName;
            customer.Phone    = model.Phone;
            var result = _customerService.Add(customer);

            if (result > 0)
            {
                return(RedirectToAction(nameof(CustomerController.List)));
            }
            else
            {
                ViewBag.ErrorMessage = "Not Saved";
                return(View(model));
            }
        }
 public void Update(long id, CustomerParam param)
 {
     Data.Entity.Customer oldEntity = CustomerDao.Find(id);
     Data.Entity.Customer newEntity = CustomerParamConverter.Convert(param, null);
     CustomerDao.Update(newEntity);
 }
Example #10
0
 public Data.Entity.Customer Update(Data.Entity.Customer entity)
 {
     Delete(entity.Id);
     Save(entity);
     return(entity);
 }
Example #11
0
 public void Delete(Data.Entity.Customer entity)
 {
     CustomerStorage.CustomerList.Remove(entity);
     CustomerStorage.CustomerDictionary.Remove(entity.Id);
 }
Example #12
0
 public void Delete(long id)
 {
     Data.Entity.Customer entity = Find(id);
     Delete(entity);
 }