示例#1
0
        public bool Run(AomFieldObjectViewModel model, ref IQueryable <AomFieldObject> repository, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result, ICoreUser user)
        {
            var updatedDbModel  = unitOfWork.With <AomFieldObject>().Single(c => c.Id == model.Id); // Might be a partial class
            var newCustomResult = AomFieldObjectMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
        public bool Run(AomFieldObjectViewModel model, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result)
        {
            var dbModel        = unitOfWork.With <AomFieldObject>().Find(model.ID);
            var updatedDbModel = AomFieldObjectMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <AomFieldObject>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AomFieldObjectMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
        public bool Run(AomFieldObjectViewModel model, ref IQueryable <AomFieldObject> repository, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result, ICoreUser user)
        {
            var dbModel        = repository.Single(c => c.Id == model.Id); // you need to be using the primary key could be composit
            var updatedDbModel = AomFieldObjectMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <AomFieldObject>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AomFieldObjectMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
示例#4
0
        public bool Run(AomFieldObjectViewModel model, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result)
        {
            var newCustom = AomFieldObjectMapper.MapInsertModelToDbModel(model);

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

            result.Data = newCustomResult;
            return(true);
        }
示例#5
0
        public Response <AomFieldObjectViewModel> Run(AomFieldObjectViewModel model, ref IQueryable <AomFieldObject> repository, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

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

            return(result);
        }
        public Response <AomFieldObjectViewModel> Run(AomFieldObjectViewModel model, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result)
        {
            var itemToUpdate = unitOfWork.With <AomFieldObject>().SingleOrDefault(c => c.Id == model.ID);

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

            return(result);
        }