public bool Run(NgTableParams model, ref IQueryable <RelationshipType> repository, NgTable <RelationshipTypes> result, ICoreUser user, IUnitOfWork db) { var ngTransformer = new QueryToNgTable <RelationshipTypesViewModel>(); var query = RelationshipTypesMapper.MapDbModelQueryToViewModelQuery(repository); ngTransformer.ToNgTableDataSet(model, query, result); return(true); }
public bool Run(RelationshipTypesViewModel model, IUnitOfWork unitOfWork, Response <RelationshipTypesViewModel> result) { var newCustom = RelationshipTypesMapper.MapInsertModelToDbModel(model); unitOfWork.With <RelationshipType>().Add(newCustom); unitOfWork.SaveChanges(); CreatedId = newCustom.Id; var newCustomResult = RelationshipTypesMapper.MapDbModelToViewModel(newCustom); result.Data = newCustomResult; return(true); }
public bool Run(RelationshipTypeViewModel model, IUnitOfWork unitOfWork, Response <RelationshipTypeViewModel> result) { var dbModel = unitOfWork.With <RelationshipType>().Find(model.Id); var updatedDbModel = RelationshipTypesMapper.MapInsertModelToDbModel(model, dbModel); unitOfWork.With <RelationshipType>().AddOrUpdate(updatedDbModel); unitOfWork.SaveChanges(); var newCustomResult = RelationshipTypesMapper.MapDbModelToViewModel(updatedDbModel); result.Data = newCustomResult; return(true); }
public Response <RelationshipTypesViewModel> Run(RelationshipTypesViewModel model, IUnitOfWork unitOfWork, Response <RelationshipTypesViewModel> result) { var itemToUpdate = unitOfWork.With <RelationshipType>().SingleOrDefault(c => c.Id == model.Id); if (itemToUpdate != null) { var newCustomResult = RelationshipTypesMapper.MapDbModelToViewModel(itemToUpdate); result.Data = newCustomResult; result.Success = true; } else { result.Success = false; result.LogError("Error viewing RelationshipTypes"); } return(result); }