public IHttpActionResult InsertRoleData(EntityRoles model) { var response = new DataResponse <EntityRoles>(); if (ModelState.IsValid) { model.CreatedBy = CurrentUserId; model.BusinessId = CurrentBusinessId; if (model.Id > 0) { response = new RepositoryRoles().Update(model); } else { response = new RepositoryRoles().Insert(model); } return(Ok <DataResponse>(response)); } else { var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new { Key = s.Key.Split('.').Last(), Message = s.Value.Errors[0].ErrorMessage }); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList })); } }
public IHttpActionResult Delete(int roleid) { var repository = new RepositoryRoles(); var response = repository.Delete(roleid); return(Ok <DataResponse>(response)); }
public IHttpActionResult GetRoleById(int?Id) { var response = new DataResponse <EntityRoles>(); var repository = new RepositoryRoles(); if (Id.HasValue) { response = repository.GetRolesById(Id.Value); } else { response.Model = new EntityRoles(); } return(Ok <DataResponse>(response)); }
public IHttpActionResult GetByFilter(FilterRoles filter) { var repository = new RepositoryRoles(); if (filter == null) { filter = new FilterRoles { PageSize = 25, CurrentPage = 1 } } ; var response = repository.GetRoles(filter, CurrentBusinessId.Value); return(Ok <DataResponse <EntityList <EntityRoles> > >(response)); }