public bool Run(AlertsViewModel model, ref IQueryable< Alert> repository, IUnitOfWork unitOfWork, Response<AlertsViewModel> result, ICoreUser user)
 {
     var updatedDbModel = unitOfWork.With< Alert>().Single(c => c.Id == model.Id); // Might be a partial class
     var newCustomResult = AlertsMapper.MapDbModelToViewModel(updatedDbModel);
     result.Data = newCustomResult;
     return true;
 }
        public bool Run(NgTableParams model, ref IQueryable <Alert> repository, NgTable <AlertsViewModel> result, ICoreUser user, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <AlertsViewModel>();

            var query = AlertsMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
        public bool Run(AlertsViewModel model, ref IQueryable <Alert> repository, IUnitOfWork unitOfWork, Response <AlertsViewModel> 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 = AlertsMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <Alert>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AlertsMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
        public Guid CreatedId; // Might be a composite key!

        public bool Run(AlertsViewModel model, IUnitOfWork unitOfWork, Response <AlertsViewModel> result, ICoreUser user)
        {
            var newCustom = AlertsMapper.MapInsertModelToDbModel(model);

            unitOfWork.With <Alert>().Add(newCustom);
            unitOfWork.SaveChanges();
            CreatedId = newCustom.Id;
            model.Id  = CreatedId; // Might be a composit key
            var newCustomResult = AlertsMapper.MapDbModelToViewModel(newCustom);

            result.Data = newCustomResult;
            return(true);
        }
        public Response <AlertsViewModel> Run(AlertsViewModel model, ref IQueryable <Alert> repository, IUnitOfWork unitOfWork, Response <AlertsViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

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

            return(result);
        }