public ActionResponse Update(int id, ExchangeRatesUsageModel model) { using (var unitWork = new UnitOfWork(context)) { IMessageHelper mHelper; ActionResponse response = new ActionResponse(); var exRatesUsageList = unitWork.ExRatesUsageRepository.GetAll(); var isExRateUsageExists = (from e in exRatesUsageList where e.Source == model.Source && e.UsageSection == model.UsageSection select e).FirstOrDefault(); var isOrderExists = (from e in exRatesUsageList where e.Order == model.Order select e).FirstOrDefault(); if (isOrderExists != null) { mHelper = new MessageHelper(); response.Success = false; response.Message = mHelper.GetExRateOrderExistsMessage(); return(response); } if (isExRateUsageExists != null) { isExRateUsageExists.Order = model.Order; unitWork.ExRatesUsageRepository.Update(isExRateUsageExists); } unitWork.Save(); return(response); } }
public IActionResult Put(int id, [FromBody] ExchangeRatesUsageModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var response = service.Update(id, model); if (!response.Success) { return(BadRequest(response.Message)); } return(Ok(true)); }