public ActionResult Action(tblDistributor objSubmit)
        {
            if (objSubmit.ID == 0)
            {
                objSubmit.DateCreated = DateTime.Now;
                objSubmit.DateUpdated = DateTime.Now;
                objSubmit.IsDeleted   = false;
                objSubmit.IsShow      = true;
                distributorRepository.Add(objSubmit);
            }
            else
            {
                var obj = distributorRepository.GetById <tblDistributor>(objSubmit.ID);

                UpdateModel(obj);

                objSubmit.DateUpdated = DateTime.Now;

                distributorRepository.Update(obj);
            }

            return(Json(new
            {
                Error = false
            }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
            public async Task <string> Handle(CreateDistributorCommand request, CancellationToken cancellationToken)
            {
                var distributor = new Distributor(request.Name);

                foreach (var areaId in request.AreasIds)
                {
                    var area = await _distributorRepository.FindAreaById(areaId);

                    if (area == null)
                    {
                        throw new AreaNotFoundException(areaId);
                    }
                    distributor.AddArea(area);
                }

                _distributorRepository.Add(distributor);

                await _distributorRepository.UnitOfWork.SaveEntitiesAsync();

                return(distributor.Id.ToString());
            }
예제 #3
0
 public bool SaveDistributor(Distributor distributor)
 {
     distributorRepository.Add(distributor);
     distributorRepository.SaveChanges();
     return(true);
 }
예제 #4
0
        public IActionResult AddDistributor([FromBody] Distributor model)
        {
            _repo.Add(model);

            return(new OkObjectResult(new { Distributorid = model.DistributorId }));
        }