public virtual void Add(TEntity entity) { try { _entityRepository.Create(entity); SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void AddRole(Role model) { var roles = roleService.GetAll(); if (roles.Exists(x => x.RoleName.Equals(model.RoleName))) { var role = roles.SingleOrDefault(x => x.RoleName.Equals(model.RoleName)); role.Description = model.Description; role.ModifiedBy = model.ModifiedBy; role.ModifiedDate = DateTime.Now; role.RecordStatus = (int)RecordStatus.Active; roleService.Update(role); } else { roleService.Create(model); } _unitOfWork.Save(); }