public ServiceResult Add(ApplyRuleModel model) { var oldEntityId = _repository.GetAll() .Where(x => x.Site == model.Site) .Select(x => x.Id) .FirstOrDefault(); if (oldEntityId != null) { _repository.Delete(oldEntityId); } var entity = _mapper.Map <Rule>(model); _repository.Add(entity); return(ServiceResult.Success); }
public IActionResult Add([FromBody] ApplyRuleModel model) { var result = _ruleService.Add(model); return(ResultFromService(result)); }