public bool Run(RelationshipObjectViewModel model, IUnitOfWork unitOfWork, Response <RelationshipObjectViewModel> result)
    {
        var newCustom = RelationshipObjectMapper.MapInsertModelToDbModel(model);

        unitOfWork.With <RelationshipObject>().Add(newCustom);
        unitOfWork.SaveChanges();
        CreatedId = newCustom.Id;
        var newCustomResult = RelationshipObjectMapper.MapDbModelToViewModel(newCustom);

        result.Data = newCustomResult;
        return(true);
    }
    public bool Run(RelationshipObjectViewModel model, IUnitOfWork unitOfWork, Response <RelationshipObjectViewModel> result)
    {
        var dbModel        = unitOfWork.With <RelationshipObject>().Find(model.Id);
        var updatedDbModel = RelationshipObjectMapper.MapInsertModelToDbModel(model, dbModel);

        unitOfWork.With <RelationshipObject>().AddOrUpdate(updatedDbModel);
        unitOfWork.SaveChanges();
        var newCustomResult = RelationshipObjectMapper.MapDbModelToViewModel(updatedDbModel);

        result.Data = newCustomResult;
        return(true);
    }
Esempio n. 3
0
    public Response <RelationshipObjectViewModel> Run(RelationshipObjectViewModel model, IUnitOfWork unitOfWork, Response <RelationshipObjectViewModel> result)
    {
        var itemToUpdate = unitOfWork.With <RelationshipObject>().SingleOrDefault(c => c.Id == model.Id);

        if (itemToUpdate != null)
        {
            var newCustomResult = RelationshipObjectMapper.MapDbModelToViewModel(itemToUpdate);
            result.Data    = newCustomResult;
            result.Success = true;
        }
        else
        {
            result.Success = false;
            result.LogError("Error viewing RelationshipObject");
        }

        return(result);
    }