public ApiSimpleResult<RoleModel> DeleteRole(RoleModel role)
 {
     var response = AccountSvc.DeleteRole(role);
     return response;
 }
        public ApiSimpleResult<RoleModel> SaveRole(RoleModel role)
        {
            var result = new ApiSimpleResult<RoleModel>();
            var response = AccountSvc.SaveRole(role);
            if (response != null)
            {
                result.Data = response;
            }

            return result;
        }
 public ApiSimpleResult<RoleModel> DeleteRole(RoleModel role)
 {
     var status = db.GeneralStatuses.Find(role.GeneralStatus.StatusId);
     db.Entry(status).State = EntityState.Deleted;
     var updateRole = db.Roles.Find(role.RoleId);
     db.Entry(updateRole).State = EntityState.Deleted;
     ApiSimpleResult<RoleModel> result = new ApiSimpleResult<RoleModel>();
     try
     {
         db.SaveChanges();
         result.StatusString = "Successful";
         result.Message = "Delete data successfully";
         result.Data = role;
     }
     catch (DbUpdateConcurrencyException ex)
     {
         result.Message = "Error";
         result.StatusString = "Error";
     }
     return result;
 }
 public RoleModel SaveRole(RoleModel role)
 {
     var result = new RoleModel();
     var status = db.GeneralStatuses.Find(role.GeneralStatus.StatusId);
     status.UpdateTime = DateTime.Now;
     status.StatusName = role.Status;
     db.Entry(status).State = EntityState.Modified;
     var updateRole = db.Roles.Find(role.RoleId);
     updateRole.RoleName = role.RoleName;
     updateRole.Note = role.Note;
     db.Entry(updateRole).State = EntityState.Modified;
     try
     {
         db.SaveChanges();
         result.RoleId = role.RoleId;
     }
     catch (DbUpdateConcurrencyException ex)
     {
         return null;
     }
     return result;
 }
 public RoleModel CreateRole(RoleModelQuery roleModelQuery)
 {
     RoleModel result = new RoleModel();
     var status = new GeneralStatus
     {
         StatusName = roleModelQuery.Status,
         CreateTime = DateTime.Now,
         UpdateTime = DateTime.Now
     };
     db.GeneralStatuses.Add(status);
     var role = new Role
     {
         RoleName = roleModelQuery.RoleName,
         StatusId = status.StatusId,
         Note = roleModelQuery.Note
     };
     db.Roles.Add(role);
     db.SaveChanges();
     result = new RoleModel
     {
         RoleId = role.RoleId,
         RoleName = role.RoleName,
     };
     return result;
 }
 public RoleModel GetRoleDetail(int roleId)
 {
     RoleModel result = new RoleModel();
     var roles = db.Roles.Where(r => r.RoleId == roleId);
     if (roles.Any())
     {
         var role = roles.First();
         result.RoleId = role.RoleId;
         result.RoleName = role.RoleName;
         result.Note = role.Note;
         result.GeneralStatus = role.Status;
         result.Status = role.Status.StatusName;
     }
     return result;
 }