public ViewModels.Customer Add(BindingModels.Customer customerBindingModel) { if (customerBindingModel == null) { throw new ArgumentNullException(nameof(customerBindingModel)); } var customerEntity = AutoMapper.Mapper.Map <Entities.Customer>(customerBindingModel); var addedCustomer = _unitOfWork.RepositoryFor <Entities.Customer>().Insert(customerEntity); _unitOfWork.SaveChanges(); return(AutoMapper.Mapper.Map <ViewModels.Customer>(addedCustomer)); }
public IHttpActionResult Put([FromUri] Guid id, [FromBody] BindingModels.Customer customerBindingModel) { if (id != customerBindingModel.Id) { return(BadRequest("Customer ID is not same.")); } bool result = _customersManager.Update(customerBindingModel); if (result) { return(Ok()); } return(NotFound()); }
public bool Update(BindingModels.Customer customerBindingModel) { if (customerBindingModel == null) { throw new ArgumentNullException(nameof(customerBindingModel)); } var customerEntity = AutoMapper.Mapper.Map <Entities.Customer>(customerBindingModel); bool result = _unitOfWork.RepositoryFor <Entities.Customer>().Update(customerEntity); if (result) { _unitOfWork.SaveChanges(); } return(result); }
public IHttpActionResult Post([FromBody] BindingModels.Customer customerBindingModel) { var result = _customersManager.Add(customerBindingModel); return(Ok(result)); }