public ActionResult Create(CreateHarvestingPlanInput input, HttpPostedFileBase path)
        {
            CheckModelState();

            try
            {
                if (path.ContentLength > 0)
                {
                    var FileName = path.FileName;
                    var FilePath = Path.Combine(Server.MapPath("~/App_Data/Documents"), FileName);

                    input.Path = FilePath;

                    _harvestingPlanAppService.CreateHarvestingPlan(input);

                    path.SaveAs(FilePath);
                }
                else
                {
                    ModelState.AddModelError("", "Please attach require paths");
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Index"));
            }
        }
        public async Task CreateHarvestingPlan(CreateHarvestingPlanInput input)
        {
            //get current active financial year;
            var current = _financialYearRepository.FirstOrDefault(c => c.IsActive == true);

            if (current != null)
            {
                var plan = new HarvestingPlan
                {
                    StationId       = input.StationId,
                    FinancialYearId = current.Id,
                    Path            = input.Path
                };

                var existingPlan = _harvestingPlanRepository.FirstOrDefault(p => p.FinancialYearId == current.Id);
                if (existingPlan == null)
                {
                    await _harvestingPlanRepository.InsertAsync(plan);
                }
                else
                {
                    throw new UserFriendlyException("There is already a Harvesting Plan with Current Financial Year");
                }
            }
            else
            {
                throw new UserFriendlyException("No Active Financial Year");
            }
        }