Example #1
0
        public IActionResult Add(Fund fund)
        {
            var result = _fundService.Add(fund);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Example #2
0
        public ActionResult Create(FundAddViewModel viewmodel)
        {
            if (ModelState.IsValid)
            {
                if (_gpDynamicsService.GetAllFunds().FirstOrDefault(t => t.Number.Trim() == viewmodel.FundNumber) == null)
                {
                    Danger($"This fund number <strong>{viewmodel.FundNumber}</strong>, does not exist in GP Databse");
                }
                else if (_fundService.GetByFundNumberAndYear(viewmodel.FundNumber, viewmodel.Year.Value) != null)
                {
                    Danger($"A Fund with same Number <strong>{viewmodel.FundNumber}</strong> already exists within the same year <strong>{viewmodel.Year.Value}</strong>.");
                }
                else
                {
                    var entity = Mapper.Map <FundAddViewModel, Fund>(viewmodel);
                    _fundService.Add(new List <Fund>()
                    {
                        entity
                    });

                    Success($"<strong>{entity.DisplayName} - {entity.FundNumber}</strong> was successfully saved.");
                    return(RedirectToAction("Index", new { year = entity.Year, dbsource = entity.DbSource }));
                }
            }
            viewmodel.AvailableDbSources = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = DbSource.GC.ToString(), Value = ((int)DbSource.GC).ToString()
                },
                new SelectListItem()
                {
                    Text = DbSource.DIST.ToString(), Value = ((int)DbSource.DIST).ToString()
                }
            };
            return(View(viewmodel));
        }
Example #3
0
        public async Task <Guid> Add(FundModel fund)
        {
            var fundDTO = _mapper.Map <FundDTO>(fund);

            return(await _fundService.Add(fundDTO));
        }