Ejemplo n.º 1
0
        public IActionResult AddOrUpdateRegistrationRequest([FromForm] RegistrationRequestViewModel model)
        {
            try
            {
                if (model == null)
                {
                    throw new ArgumentNullException(nameof(model), "Model cannot be null or empty");
                }

                if (model.IsValid(ModelState) == false)
                {
                    model.LoadMaritalStatuses(registrationRequestRepository);
                    model.LoadRelationships(registrationRequestRepository);
                    model.LoadStatesOfMexico(registrationRequestRepository);
                    model.LoadMunicipalitiesOfMexico(registrationRequestRepository);
                    model.LoadRegistrationRequestStatuses(registrationRequestRepository);
                    model.CreationDate = DateTime.Now.ToCentralMexicoTime();

                    return(View("ShowForm", model));
                }

                if (model.Id > 0) // update item
                {
                    registrationRequestRepository.Update(model);
                }
                else // add new item
                {
                    registrationRequestRepository.Add(model);
                }
            }
            catch (BusinessLogicException ex)
            {
                ModelState.AddModelError("", ex.Message);
                model.LoadMaritalStatuses(registrationRequestRepository);
                model.LoadRelationships(registrationRequestRepository);
                model.LoadStatesOfMexico(registrationRequestRepository);
                model.LoadMunicipalitiesOfMexico(registrationRequestRepository);
                model.LoadRegistrationRequestStatuses(registrationRequestRepository);

                return(View("ShowForm", model));
            }
            catch (Exception)
            {
                throw;
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public IActionResult Print(int?Id)
        {
            HttpContext.JsReportFeature().Recipe(Recipe.ChromePdf);
            RegistrationRequestViewModel model = new RegistrationRequestViewModel();

            if (Id > 0) // item is stored in database already
            {
                var registration = registrationRequestRepository.GetRegistrationRequestById(Convert.ToInt32(Id));
                model.Comments           = registration.Comments;
                model.CreationDate       = registration.CreationDate;
                model.EconomicSituation  = registration.EconomicSituation;
                model.FamilyComposition  = registration.FamilyComposition;
                model.FamilyHealthStatus = registration.FamilyHealthStatus;
                model.FamilyInteraction  = registration.FamilyInteraction;
                model.HowYouHearAboutUs  = registration.HowYouHearAboutUs;
                model.Id          = registration.Id;
                model.Minor       = registration.Minor;
                model.MinorId     = registration.MinorId;
                model.Reasons     = registration.Reasons;
                model.Requestor   = registration.Requestor;
                model.RequestorId = registration.RequestorId;
                model.SituationsOfDomesticViolence = registration.SituationsOfDomesticViolence;
                model.RegistrationRequestStatus    = registration.RegistrationRequestStatus;
                model.RegistrationRequestStatusId  = registration.RegistrationRequestStatusId;
                model.LoadMunicipalitiesOfMexico(registrationRequestRepository);
                model.LoadRegistrationRequestStatuses(registrationRequestRepository);
                model.SocialWorkerName = registration.SocialWorkerName;

                return(View(model));
            }

            return(View(model));
        }
Ejemplo n.º 3
0
        public IActionResult ShowForm(int?Id)
        {
            RegistrationRequestViewModel model = new RegistrationRequestViewModel();

            model.LoadMaritalStatuses(registrationRequestRepository);
            model.LoadRelationships(registrationRequestRepository);
            model.LoadStatesOfMexico(registrationRequestRepository);
            model.LoadMunicipalitiesOfMexico(registrationRequestRepository);
            model.LoadRegistrationRequestStatuses(registrationRequestRepository);
            model.CreationDate = DateTime.Now.ToCentralMexicoTime();

            if (Id > 0) // item is stored in database already
            {
                var registration = registrationRequestRepository.GetRegistrationRequestById(Convert.ToInt32(Id));
                model.Comments           = registration.Comments;
                model.CreationDate       = registration.CreationDate;
                model.EconomicSituation  = registration.EconomicSituation;
                model.FamilyComposition  = registration.FamilyComposition;
                model.FamilyHealthStatus = registration.FamilyHealthStatus;
                model.FamilyInteraction  = registration.FamilyInteraction;
                model.HowYouHearAboutUs  = registration.HowYouHearAboutUs;
                model.Id          = registration.Id;
                model.Minor       = registration.Minor;
                model.MinorId     = registration.MinorId;
                model.Reasons     = registration.Reasons;
                model.Requestor   = registration.Requestor;
                model.RequestorId = registration.RequestorId;
                model.SituationsOfDomesticViolence = registration.SituationsOfDomesticViolence;
                model.RegistrationRequestStatus    = registration.RegistrationRequestStatus;
                model.RegistrationRequestStatusId  = registration.RegistrationRequestStatusId;
                model.LoadMunicipalitiesOfMexico(registrationRequestRepository);
                model.LoadRegistrationRequestStatuses(registrationRequestRepository);
                model.SocialWorkerName = registration.SocialWorkerName;

                return(View(model));
            }

            return(View(model));
        }