Exemple #1
0
        public IActionResult Create([FromBody] AddOrEditTenderViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var tender = Mapper.Map <AddOrEditTenderViewModel, Tender>(vm);
                DbContext.Add <Tender>(tender);
                DbContext.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }

            return(View(vm));
        }
        public async Task <IActionResult> Create([Bind("TenderId,BuildingId")] TenderObject tenderObject)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tenderObject);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BuildingId"] = new SelectList(_context.Buildings, "Id", "Address", tenderObject.BuildingId);
            ViewData["TenderId"]   = new SelectList(_context.Tenders, "Id", "DkrNumber", tenderObject.TenderId);
            return(View(tenderObject));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("ShortName", "FullName")] DistrictViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var newDistrict = Mapper.Map <DistrictViewModel, District>(vm);
                DbContext.Add(newDistrict);
                await DbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(vm));
        }