public IHttpActionResult InsertRepgroupData(EntityRepGroups model) { var response = new DataResponse <EntityRepGroups>(); if (ModelState.IsValid) { model.UpdatedBy = model.CreatedBy = CurrentUserId; model.BusinessId = CurrentBusinessId; if (model.Id > 0) { response = new RepositoryRepGroups().Update(model); } else { response = new RepositoryRepGroups().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 repgroupid) { var repository = new RepositoryRepGroups(); var response = repository.Delete(repgroupid); return(Ok <DataResponse>(response)); }
public IHttpActionResult GetRepGroupById(int?Id) { var response = new DataResponse <EntityRepGroups>(); var repository = new RepositoryRepGroups(); if (Id.HasValue) { response = repository.GetRepGroupById(Id.Value); } else { response.Model = new EntityRepGroups(); } return(Ok <DataResponse>(response)); }
public IHttpActionResult GetByFilter(FilterRepGroups filter) { var repository = new RepositoryRepGroups(); if (filter == null) { filter = new FilterRepGroups { PageSize = 25, CurrentPage = 1 } } ; var response = repository.GetRepGroups(filter, CurrentBusinessId.Value); return(Ok <DataResponse <EntityList <EntityRepGroups> > >(response)); }