public async Task <IActionResult> Create([Bind("IndicatorId,IndicatorId1,IndicatorId2,IndicatorId3,IndicatorName,IndicatorUnit,IndicatorType,IndicatorDescription,Year")] Indicator indicator)
        {
            if (ModelState.IsValid)
            {
                _context.Add(indicator);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(indicator));
        }
        public string Create([Bind("IndicatorId1,IndicatorId2,IndicatorId3,IndicatorName,IndicatorUnit,IndicatorType,IndicatorDescription,Year")] Indicator indicator)
        {
            string msg = "Модель не прошла валидацию";

            if (ModelState.IsValid)
            {
                _context.Add(indicator);
                _context.SaveChanges();
                msg = "Сохранено";
                return(msg);
            }
            return(msg);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("UniversityId,UniversityName,Address,Website,Logo")] University university, IFormFile upload)
        {
            if (ModelState.IsValid)
            {
                var universityWithLogo = await _externalFile.UploadUniversityWithLogo(university, upload);

                _context.Add(universityWithLogo);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(university));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("DocumentId,RegistrationNumber,DocumentName,DocumentDescription,RegistrationDate,DocumentURL,ChairpersonId")] Document document, IFormFile upload)
        {
            if (ModelState.IsValid)
            {
                var documentWithFile = await _externalFile.UploadDocument(document, upload);

                _context.Add(documentWithFile);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ChairpersonId"] = new SelectList(_context.Chairpersons.Include(r => r.Rector), "ChairpersonId", "Rector.FullName", document.ChairpersonId);
            return(View(document));
        }
        public async Task <IActionResult> Create([Bind("ChairpersonId,StartDate,StopDate,RectorId")] Chairperson chairperson)
        {
            if (ModelState.IsValid)
            {
                if (_context.Chairpersons.Where(d => d.StopDate == null).Count() > 0)
                {
                    return(View("Message", "”же существует действующий председатель!"));
                }
                _context.Add(chairperson);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewData["RectorId"] = new SelectList(_context.Rectors, "RectorId", "FullName", chairperson.RectorId);
            return(View(chairperson));
        }
        public async Task <IActionResult> Create(Rector rector, IFormFile upload)
        {
            if (ModelState.IsValid)
            {
                var rectorWithPhoto = await _externalFile.UploadRectorWithPhoto(rector, upload);

                _context.Add(rectorWithPhoto);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            EditRectorViewModel rectorView = new EditRectorViewModel()
            {
                CurrentRector = rector,
                Universities  = _context.Universities,
                Rectors       = _context.Rectors
            };

            ViewData["UniversityId"] = rectorView.ListUniversities;
            return(View(rector));
        }