//Create public int CreateAndReturnId(CreateExportDetail input) { try { //get current active financial year; var currentYr = _financialYearRepository.FirstOrDefault(c => c.IsActive == true); var export = new ExportDetail { ApplicantId = input.ApplicantId, SpecieCategoryId = input.SpecieCategoryId, StationId = input.StationId, FinancialYearId = currentYr.Id, BankName = input.BankName, BankAddress = input.BankAddress, Destination = input.Destination, ShipmentDate = input.ShipmentDate }; return(_exportDetailRepository.InsertAndGetId(export)); } catch (Exception ex) { throw new UserFriendlyException(ex.Message); } }
public ActionResult Create(CreateExportDetail Input) { try { // TODO: Add insert logic here if (ModelState.IsValid) { int exportDetailId = _exportService.CreateAndReturnId(Input); return(RedirectToAction("addSpecie", new { Id = exportDetailId })); } else { ViewBag.Applicant = _applicantService.GetApplicantById(_userAppService.GetLoggedInUser().ApplicantId); ViewBag.StationId = _stationAppService.GetStations().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); ViewBag.SpecieCategoryId = _specieCategoryAppService.GetSpecieCategories().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); return(View(Input)); } } catch { ViewBag.Applicant = _applicantService.GetApplicantById(_userAppService.GetLoggedInUser().ApplicantId); ViewBag.StationId = _stationAppService.GetStations().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); ViewBag.SpecieCategoryId = _specieCategoryAppService.GetSpecieCategories().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); return(View()); } }