public bool UpdateUserType(UserTypeDto dto) { var userType = this.db.UserTypes.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (userType != null) { userType.UpdatedOn = DateTime.Now; userType.UpdatedBy = dto.UpdatedBy; userType.Comment = dto.Comment; userType.Name = dto.Name; userType.Description = dto.Description; this.db.SaveChanges(); return true; } return false; }
public bool AddUserType(UserTypeDto dto) { if (!this.db.UserTypes.Any(x => x.DeletedOn.HasValue == false && x.Id == dto.Id)) { this.db.UserTypes.Add(new UserType { CreatedOn = DateTime.Now, UpdatedOn=DateTime.Now, UpdatedBy = dto.UpdatedBy, Comment = dto.Comment, Name = dto.Name, Description = dto.Description }); this.db.SaveChanges(); return true; } return false; }