public IResult Insert(Person item, Guid userId) { item.StatusId = ActiveStatus.Active; item.CreatedUserId = userId; item.ModifiedUserId = userId; item.UtcCreatedDate = DateTime.Now; item.UtcModifiedDate = DateTime.Now; var entityError = new List<EntityError>(); try { if (item.Id == Guid.Empty) item.Id = Guid.NewGuid(); Guid? id = item.Id; PersonDb.Insert( ref id, item.FirstName, item.Surname, item.EmailAddress, item.PhoneHome, item.PhoneMobile, item.PhoneOffice, item.Fax, item.Description, item.Gender, item.Disability, item.DisabilityNote, item.PreferredName, (int)item.StatusId, userId); return new InsertResult(); } catch (Exception ex) { entityError.Add(new EntityError("Person", "Insert", ex.Message.ToString())); return new InsertResult(entityError); } }
public IResult Update(Person item, Guid userId) { item.UtcModifiedDate = DateTime.Now; try { PersonDb.Update( item.Id, item.FirstName, item.Surname, item.EmailAddress, item.PhoneHome, item.PhoneMobile, item.PhoneOffice, item.Description, item.Fax, item.Gender, item.Disability, item.DisabilityNote, item.PreferredName, (int)item.StatusId, userId); return new UpdateResult(); } catch (SqlException ex) { var entityError = new List<EntityError>(); entityError.Add(new EntityError("Person", "Update", ex.InnerException.ToString())); return new UpdateResult(entityError); } }