public async Task <string> InsertAsync(FiscalYearDto dto) { var currentFiscalYear = await GetCurrentFiscalYearAsync(); var con = _baseInterface.GetConnection(); var transaction = con.BeginTransaction(); string message = ""; try { if (dto.IsCurrent) { _fiscalYearRepository.MakeIsCurrentFalse(con, transaction); } else { if (currentFiscalYear is null) { dto.IsCurrent = true; } } dto.StartDateAD = Convert.ToDateTime(_dateService.ConvertToEnglishDate(dto.StartDateBS)); dto.EndDateAD = Convert.ToDateTime(_dateService.ConvertToEnglishDate(dto.EndDateBS)); int result = _fiscalYearRepository.Insert(dto.ToEntity(), transaction, con); message = _messageClass.ShowSuccessMessage(result); transaction.Commit(); } catch (SqlException ex) { message = _messageClass.ShowErrorMessage(string.Format("{0} ~ {1}", ex.Number.ToString(), ex.Message)); transaction.Rollback(); } return(message); }
public async Task <string> Post(FiscalYearDto dto) { if (!menu.WriteAccess) { return(null); } return(await _fiscalYearService.InsertAsync(dto)); }
public async Task <string> Put(FiscalYearDto dto) { if (!menu.ModifyAccess) { return(null); } return(await _fiscalYearService.UpdateAsync(dto)); }
public ActionResult AddFiscalYear() { if (!menu.WriteAccess) { return(RedirectToAction("Logout", "Account")); } var obj = new FiscalYearDto(); return(View("AddModifyFiscalYear", obj)); }
public IActionResult edit(long FiscalYear_id) { try { var fiscalYear = _fiscalYearRepository.getById(FiscalYear_id); FiscalYearDto dto = _mapper.Map <FiscalYearDto>(fiscalYear); // RouteData.Values.Remove("FiscalYear_id"); return(View(dto)); } catch (Exception ex) { AlertHelper.setMessage(this, ex.Message, messageType.error); return(RedirectToAction("index")); } }
public IActionResult edit(FiscalYearDto FiscalYear_dto) { try { if (ModelState.IsValid) { _fiscalYearService.update(FiscalYear_dto); AlertHelper.setMessage(this, "Fiscal Year updated successfully."); return(RedirectToAction("index")); } } catch (Exception ex) { AlertHelper.setMessage(this, ex.Message, messageType.error); } return(View(FiscalYear_dto)); }
public void save(FiscalYearDto fiscal_year_dto) { try { using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) { FiscalYear fiscalYear = new FiscalYear(); _fiscalYearMaker.copy(ref fiscalYear, fiscal_year_dto); _fiscalYearRepo.insert(fiscalYear); tx.Complete(); } } catch (Exception) { throw; } }
public void update(FiscalYearDto fiscal_year_dto) { try { using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) { FiscalYear fiscalYear = _fiscalYearRepo.getById(fiscal_year_dto.fiscal_year_id); if (fiscalYear == null) { throw new ItemNotFoundException($"Fiscal Year with ID {fiscal_year_dto.fiscal_year_id} doesnot Exit."); } _fiscalYearMaker.copy(ref fiscalYear, fiscal_year_dto); _fiscalYearRepo.update(fiscalYear); tx.Complete(); } } catch (Exception) { throw; } }
public IActionResult add(FiscalYearDto model, IFormFile file = null) { try { if (ModelState.IsValid) { if (file != null) { string fileName = model.name; model.name = _fileHelper.saveImageAndGetFileName(file, fileName); } _fiscalYearService.save(model); AlertHelper.setMessage(this, "Fiscal Year saved successfully.", messageType.success); return(RedirectToAction("index")); } } catch (Exception ex) { AlertHelper.setMessage(this, ex.Message, messageType.error); } return(View(model)); }
public static FiscalYear ToEntity(this FiscalYearDto dto) { if (dto == null) { return(null); } return(new FiscalYear { FiscalYearId = dto.FiscalYearId, Name = dto.Name?.Trim(), NepaliName = dto.NepaliName?.Trim(), StartDateBS = dto.StartDateBS?.Trim(), StartDateAD = dto.StartDateAD, EndDateBS = dto.EndDateBS?.Trim(), EndDateAD = dto.EndDateAD, IsCurrent = dto.IsCurrent, Status = dto.Status, CreatedBy = dto.CreatedBy, CreatedDate = dto.CreatedDate, UpdatedBy = dto.UpdatedBy, UpdatedDate = dto.UpdatedDate, }); }
public void copy(ref FiscalYear fiscalYear, FiscalYearDto fiscalYearDto) { fiscalYear.fiscal_year_id = fiscalYearDto.fiscal_year_id; fiscalYear.name = fiscalYearDto.name; fiscalYear.is_current = fiscalYearDto.is_current; }