Esempio n. 1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(PitchEvent).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PitchEventExists(PitchEvent.PitchEventId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            //if updating mentor
            if (MentorAssignment.MentorAssignmentId > 0)
            {
                //get application
                MentorAssignment.Application = _repository.GetApplicationById(MentorAssignment.ApplicationId);

                //update status only if current status is Approved to avoid regressing status of application in later stages
                if (MentorAssignment.Application.ApplicationStatusId == _repository.GetStatusIdByName("Approved"))
                {
                    MentorAssignment.Application.ApplicationStatusId = _repository.GetStatusIdByName("Assigned to Mentor");
                }
                _context.Attach(MentorAssignment).State = EntityState.Modified;
                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MentorAssignmentExists(MentorAssignment.MentorAssignmentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            else   //if first time adding mentor
            {
                //get application
                MentorAssignment.Application = _repository.GetApplicationById(MentorAssignment.ApplicationId);
                //update status
                MentorAssignment.Application.ApplicationStatusId = _repository.GetStatusIdByName("Assigned to Mentor");
                _context.MentorAssignment.Add(MentorAssignment);
                await _context.SaveChangesAsync();
            }

            var noti = new Notification();

            noti.UserID = MentorAssignment.MentorId;
            noti.NotificationMessage = "New assignment: " + MentorAssignment.Application.CompanyName;
            _context.Notifications.Add(noti);
            _context.SaveChanges();
            return(RedirectToPage("./Index"));
        }