示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("StatusId,Content")] VolunteerStatus volunteerStatus)
        {
            if (id != volunteerStatus.StatusId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(volunteerStatus);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VolunteerStatusExists(volunteerStatus.StatusId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(volunteerStatus));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("StatusId,Content")] VolunteerStatus volunteerStatus)
        {
            if (ModelState.IsValid)
            {
                _context.Add(volunteerStatus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(volunteerStatus));
        }
        public static string ToPortugueseString(this VolunteerStatus status)
        {
            switch (status)
            {
            case VolunteerStatus.Waiting:
                return("Pendente");

            case VolunteerStatus.Active:
                return("Aprovado");

            case VolunteerStatus.Blocked:
                return("Rejeitado");

            default:
                throw new ArgumentOutOfRangeException(nameof(status), status, null);
            }
        }