public CrudReport Validate <ENTITY>(ENTITY entity) where ENTITY : DomainEntity { var crudReport = new CrudReport(); var runner = new ValidatorRunner(registry); if (runner.IsValid(entity)) { crudReport.Success = true; } else { crudReport.AddErrorInfos(GetErrors(entity)); } return(crudReport); }
public ICrudManager DecrementTaskProduct(Task task, ICrudManager crudManager = null) { if (crudManager == null) { crudManager = new CrudManager(_repository); } if (task.InventoryProduct == null) { return(crudManager); } if (!task.QuantityUsed.HasValue) { var crudReport = new CrudReport { Success = false }; crudReport.AddErrorInfo(new ErrorInfo("QuantityUsed", CoreLocalizationKeys.QUANTITY_USED_REQUIRED.ToString())); crudManager.AddCrudReport(crudReport); return(crudManager); } task.InventoryProduct.Quantity -= task.QuantityUsed.Value; return(_saveEntityService.ProcessSave(task.InventoryProduct, crudManager)); }
public ICrudManager SaveUploadedFile(string systemFolder, string fileNameNoExtension, ICrudManager crudManager) { var file = _sessionContext.RetrieveUploadedFile(); if (file == null || file.ContentLength <= 0 || crudManager.HasFailingReport()) return crudManager; var folderPath = _sessionContext.MapPath(systemFolder); var extension = file.FileName.Substring(file.FileName.LastIndexOf(".")); var newName = fileNameNoExtension + extension; string filePath = folderPath + "\\" + newName; var exists = Directory.Exists(folderPath); if (!exists) { Directory.CreateDirectory(folderPath); } //TODO insert rules engine here var fileExists = File.Exists(filePath); CrudReport crudReport= new CrudReport(); if (fileExists) { crudReport.AddErrorInfo(new ErrorInfo(null,WebLocalizationKeys.FILE_ALREADY_EXISTS.ToString())); crudManager.AddCrudReport(crudReport); return crudManager; } file.SaveAs(filePath); crudReport.Success = true; crudManager.AddCrudReport(crudReport); return crudManager; }
public void AddCrudReport(CrudReport crudReport) { _crudReports.Add(crudReport); }
public void RemoveCrudReport(CrudReport crudReport) { _crudReports.Remove(crudReport); }