public string Execute(Domain.Standard.Standard standard) { string response = _standardRepository.Add(standard); switch (response) { case "NameExist": throw new DuplicateEntityException(standard.Name, "Ya existe una norma con este nombre o código", 436); case "OneActive": throw new DuplicateEntityException(standard.Name, "Debe existir al menos un aspecto activo.", 436); default: return("Ok"); } }
/// <summary> /// The Save /// </summary> /// <param name="entity">The entity<see cref="Standard"/></param> /// <returns>The <see cref="ServiceResult"/></returns> public ServiceResult Save(Standard entity) { try { if (entity.Identifier == 0) { _repository.Add(entity); } else { _repository.Update(entity); } return(new ServiceResult(true)); } catch (Exception ex) { return(new ServiceResult(false) { Error = ex.ToString() }); } }