예제 #1
0
    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);
    }
예제 #2
0
    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);
    }
예제 #3
0
    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);
    }
예제 #4
0
    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);
    }