public async Task <IActionResult> Edit(Document document)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(document);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!DocumentExists(document.DocumentId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         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> Edit([Bind("IndicatorId,IndicatorId1,IndicatorId2,IndicatorId3,IndicatorName,IndicatorUnit,IndicatorType,IndicatorDescription,Year")] Indicator indicator)
        {
            if (User.IsInRole("user") && (DateTime.Now.Hour < 7 || DateTime.Now.Hour > 17))
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }


            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(indicator);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IndicatorExists(indicator.IndicatorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", new { currentYear = indicator.Year, disableForEdition = false }));
            }
            return(View(indicator));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(University university, IFormFile upload)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    university = await _externalFile.UploadUniversityWithLogo(university, upload);

                    _context.Update(university);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UniversityExists(university.UniversityId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(university));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ChairpersonId,StartDate,StopDate,RectorId")] Chairperson chairperson)
        {
            if (id != chairperson.ChairpersonId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(chairperson);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChairpersonExists(chairperson.ChairpersonId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RectorId"] = new SelectList(_context.Rectors, "RectorId", "FullName", chairperson.RectorId);
            return(View(chairperson));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Newsid,UnivercityId,Header,Message,PublicDate")] News news)
        {
            if (id != news.Newsid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(news);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NewsExists(news.Newsid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UnivercityId"] = new SelectList(_context.Universitys, "UniversityId", "UniversityName", news.UnivercityId);
            return(View(news));
        }
Exemple #6
0
        // GET: Achievements/Edit/5
        public string Edit(Achievement achievement)
        {
            string msg = "Модель не прошла валидацию";

            if (ModelState.IsValid)
            {
                try
                {
                    achievement.UnivercityId = GetUniversiryId();
                    msg = "Сохранено";
                    _context.Update(achievement);
                    _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AchievementExists(achievement.AchievementId))
                    {
                        msg = "Не найдено";
                        return(msg);
                    }
                    else
                    {
                        throw;
                    }
                }
                return(msg);
            }
            return(msg);
        }
        public async Task <IActionResult> Edit(int id, [Bind("AchievementId,UnivercityId,IndicatorId,IndicatorValue,Position,Year")] Achievement achievement)
        {
            if (id != achievement.AchievementId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try

                {
                    _context.Update(achievement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AchievementExists(achievement.AchievementId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IndicatorId"]  = new SelectList(_context.Indicators, "IndicatorId", "IndicatorName", achievement.IndicatorId);
            ViewData["UnivercityId"] = new SelectList(_context.Universitys, "UniversityId", "UniversityName", achievement.UnivercityId);
            return(View(achievement));
        }
Exemple #8
0
        public async Task <IActionResult> Edit(Rector CurrentRector, IFormFile upload)
        {
            Rector rector = CurrentRector;

            if (ModelState.IsValid)
            {
                try
                {
                    rector = await _externalFile.UploadRectorWithPhoto(CurrentRector, upload);

                    _context.Update(rector);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RectorExists(rector.RectorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }

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

            return(View(rectorView));
        }