Пример #1
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));
        }
 public async Task <IActionResult> Edit([Bind("ChairpersonId,StartDate,StopDate,RectorId")] Chairperson chairperson)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(chairperson);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!ChairpersonExists(chairperson.ChairpersonId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction("Index"));
     }
     ViewData["RectorId"] = new SelectList(_context.Rectors, "RectorId", "FullName", chairperson.RectorId);
     return(View(chairperson));
 }
Пример #3
0
 public async Task <IActionResult> Edit([Bind("AchievementId,IndicatorId,UnivercityId,IndicatorValue,Year")] Achievement achievement)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(achievement);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!AchievementExists(achievement.AchievementId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction("Index"));
     }
     ViewData["IndicatorId"]  = new SelectList(_context.Indicators, "IndicatorId", "IndicatorName", achievement.IndicatorId);
     ViewData["UnivercityId"] = new SelectList(_context.Universities, "UniversityId", "UniversityName", achievement.UnivercityId);
     return(View(achievement));
 }
        // GET: Indicators/Edit/5
        public string Edit(Indicator indicator)
        {
            string msg = "Модель не прошла валидацию";

            if (ModelState.IsValid)
            {
                try
                {
                    msg = "Сохранено";
                    _context.Update(indicator);
                    _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IndicatorExists(indicator.IndicatorId))
                    {
                        msg = "Не найдено";
                        return(msg);
                    }
                    else
                    {
                        throw;
                    }
                }
                return(msg);
            }
            return(msg);
        }
        // GET: Achievements/Edit/5
        public string Edit(Achievement achievement)
        {
            string msg = "Модель не прошла валидацию";

            if (ModelState.IsValid)
            {
                try
                {
                    msg = "Сохранено";
                    _context.Update(achievement);
                    _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AchievementExists(achievement.AchievementId))
                    {
                        msg = "Не найдено";
                        return(msg);
                    }
                    else
                    {
                        throw;
                    }
                }
                return(msg);
            }
            return(msg);
        }
Пример #6
0
 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));
 }
Пример #7
0
        public IActionResult Put([FromBody] University university)
        {
            if (university == null)
            {
                return(BadRequest());
            }
            if (!_context.Universities.Any(x => x.UniversityId == university.UniversityId))
            {
                return(NotFound());
            }

            _context.Update(university);
            _context.SaveChanges();
            return(Ok(university));
        }
 public async Task <IActionResult> Edit([Bind("IndicatorId,IndicatorId1,IndicatorId2,IndicatorId3,IndicatorName,IndicatorUnit,IndicatorType,IndicatorDescription,Year")] Indicator indicator)
 {
     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));
 }
        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.Universities,
                Rectors       = _context.Rectors
            };

            return(View(rectorView));
        }