Пример #1
0
    public bool Run(AomObjectViewModel model, IUnitOfWork unitOfWork, Response <AomObjectViewModel> result)
    {
        var dbModel        = unitOfWork.With <AomObject>().Find(model.Id);
        var updatedDbModel = AomObjectMapper.MapInsertModelToDbModel(model, dbModel);

        unitOfWork.With <AomObject>().AddOrUpdate(updatedDbModel);
        unitOfWork.SaveChanges();
        var newCustomResult = AomObjectMapper.MapDbModelToViewModel(updatedDbModel);

        result.Data = newCustomResult;
        return(true);
    }
Пример #2
0
    public bool Run(AomObjectViewModel model, IUnitOfWork unitOfWork, Response <AomObjectViewModel> result)
    {
        var newCustom = AomObjectMapper.MapInsertModelToDbModel(model);

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

        result.Data = newCustomResult;
        return(true);
    }
Пример #3
0
    public Response <AomObjectViewModel> Run(AomObjectViewModel model, IUnitOfWork unitOfWork, Response <AomObjectViewModel> result)
    {
        var itemToUpdate = unitOfWork.With <AomObject>().SingleOrDefault(c => c.Id == model.Id);

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

        return(result);
    }