public static UploadFileType AsDatabaseModel(UploadFileTypeViewModel model) { return(new UploadFileType() { ID = model.ID, Description = model.Description, FilesPath = model.FilesPath }); }
public IActionResult AddFileType(UploadFileTypeViewModel model) { try { ExcelLoanServices.AddUploadFileType(model, _hostingEnvironment.WebRootPath); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { ErrorMessage = ex.Message })); } }
public UploadFileTypeViewModel AddUploadFileType(UploadFileTypeViewModel model, string rootPath) { model.FilesPath = "/Files/" + model.FilesPath; var path = rootPath + model.FilesPath; if (Directory.Exists(path)) { throw new Exception("ამ სახელით დირექტორია უკვე არსებობს"); } else { Directory.CreateDirectory(path); return(Transformer.AsViewModelModel(UploadFileTypeRepository.Add(Transformer.AsDatabaseModel(model)))); } }