public async Task <ActionResult> VolunteerEdit([FromForm] Volunteer volunteer)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await volRepo.UpdateVolunteer(volunteer);

                    TempData["Alert"] = "Volunteer Edited Successfully";
                    return(RedirectToAction(nameof(VolunteerIndex)));
                }
                catch (Exception ex)
                {
                    ViewBag.Error = "Unable to edit volunteer, please try again or contact administrator";
                    return(View());
                }
            }
            ViewBag.Error = "Please correct the error(s) in Form";
            return(View());
        }
        public ResultObject UpdateVolunteer(Volunteer volunteer, int currentUserId)
        {
            var validationResult = _validation.ValidateVolunteerToUpdate(volunteer, currentUserId);

            if (validationResult.Success)
            {
                var response = new ResultObject();

                var updateVolunteerSuccess = _volunteerRepository.UpdateVolunteer(volunteer);

                if (updateVolunteerSuccess)
                {
                    response.Success = true;
                    response.Message = "10026";
                    return(response);
                }

                response.Success = false;
                response.Errors.Add("10027");
                return(response);
            }

            return(validationResult);
        }
示例#3
0
        public void UpdateVolunteer(VolunteerDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "VolunteerId");

                log.Debug(VolunteerDTO.FormatVolunteerDTO(dto));

                R_Volunteer t = VolunteerDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateVolunteer(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }