public int Insert(Outage outage, out string message) { if (outage == null) { message = "Outage is invalid."; return(0); } if (outage.Id > 0) { message = "Outage cannot have an id."; return(0); } bool IsValid = OutageValidator.Validate(outage, out message); if (!IsValid) { return(0); } int id = repository.Insert(outage); if (id > 0) { message = string.Empty; } else { message = "An error occured while trying to insert outage."; } return(id); }
public bool Update(Outage outage, out string message) { if (outage == null) { message = "Outage is invalid."; return(false); } if (outage.Id <= 0) { message = "Outage id is invalid."; return(false); } bool IsValid = OutageValidator.Validate(outage, out message); if (!IsValid) { return(false); } bool result = repository.Update(outage); if (result) { message = string.Empty; } else { message = "An error occured while trying to update outage."; } return(result); }