public async Task <IActionResult> Add([FromForm] SiteSettingResource model) { var file = Request.Form.Files.FirstOrDefault(); if (file != null) { var path = Path.Combine(web.WebRootPath, "images"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var FileName = Guid.NewGuid().ToString() + "" + Path.GetFileNameWithoutExtension(file.FileName) + Path.GetExtension(file.FileName); var filePath = Path.Combine(path, FileName); model.LogoUrl = FileName; using (var stream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(stream); } } var domain = mapper.Map <SiteSetting> (model); await uow._Isite.CreateAsync(domain); await uow.CompleteAsync(); return(Ok()); }
public IActionResult Post(DartaResource darta) { if (darta == null) { return(BadRequest()); } var newDarta = _map.Map <Dartas> (darta); _Irepo.CreateAsync(newDarta).GetAwaiter().GetResult(); _uow.CompleteAsync().GetAwaiter().GetResult(); return(Ok()); }
public IActionResult Post(ChalanResource chalan) { if (chalan == null) { return(BadRequest()); } var newChalan = _map.Map <Chalan> (chalan); _uow._chalanRepo.CreateAsync(newChalan).GetAwaiter().GetResult(); _uow.CompleteAsync().GetAwaiter().GetResult(); return(Ok()); }
public IActionResult Post(SubjectResource subject) { if (subject == null) { return(BadRequest()); } var newSubject = _map.Map <Subject> (subject); _Irepo.CreateAsync(newSubject).GetAwaiter().GetResult(); _uow.CompleteAsync().GetAwaiter().GetResult(); return(Ok()); }
public async Task <IActionResult> Post([FromForm] HalsabikChalaniResource model) { if (model != null) { var domainPurji = _map.Map <HalsabikChalani> (model); var files = Request.Form.Files; if (files.Count > 0) { var root = Path.Combine(env.WebRootPath, "files", "halsabik_chalani"); if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } foreach (var file in files) { var fileName = Guid.NewGuid().ToString() + "_" + Path.GetFileNameWithoutExtension(file.FileName) + "" + Path.GetExtension(file.FileName); var filePath = Path.Combine(root, fileName); using (var stream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(stream); } var chalanFile = new HalsabikChalaniFile() { fileUrl = fileName }; domainPurji.patras.Add(new HalsabikChalaniPatras() { file = chalanFile }); } } domainPurji.subject = _ISubRepo.FilterAsync(p => p.Id == model.subjectId) .GetAwaiter().GetResult().FirstOrDefault(); await _uow._HalsabikChalani.CreateAsync(domainPurji); await _uow.CompleteAsync(); var res = _map.Map <HalsabikChalaniResource> (domainPurji); return(Ok(res)); } else { return(BadRequest()); } }
public async Task <IActionResult> Post([FromForm] FieldRekhankanDartaResource model) { if (model != null) { var domainDarta = _map.Map <FieldRekhankanDarta> (model); var files = Request.Form.Files; if (files.Count > 0) { var root = Path.Combine(env.WebRootPath, "files", "field_rekhankan_darta"); if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } foreach (var file in files) { var fileName = Guid.NewGuid().ToString() + "_" + Path.GetFileNameWithoutExtension(file.FileName) + "" + Path.GetExtension(file.FileName); var filePath = Path.Combine(root, fileName); using (var stream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(stream); } var fieldFile = new FieldRekhankanDartaFile() { fileUrl = fileName }; domainDarta.patras.Add(new RekhankanDartaPatras() { file = fieldFile }); } } await _uow._FiledDartaRepo.CreateAsync(domainDarta); await _uow.CompleteAsync(); var res = _map.Map <FieldRekhankanDartaResource> (domainDarta); return(Ok(res)); } else { return(BadRequest()); } }
public async Task <IActionResult> AddFiscal(FiscalYear model) { await fiscal.CreateAsync(model); await uow.CompleteAsync(); return(Ok()); }