Exemplo n.º 1
0
        /// <summary>
        /// Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Edit(int id)
        {
            var model = new PatientViewModel();
            model.Countries = HealthHelper.GetAllCountries();
            if (id != -1)
            {
                var svc = new PatientAppService();
                var o = svc.GetPatient(id);

                model.PatientId = o.PatientId;
                model.FirstName = o.FirstName;
                model.FirstLastName = o.FirstLastName;
                model.Gender = o.Gender;
                model.BirthDate = o.BirthDate;
                model.Identification = o.Identification;
                model.IdentificationType = o.IdentificationType;
                model.Address = o.Address;
                model.Phone = o.Phone;
                model.Mobile = o.Mobile;
                model.SecondName = o.SecondName;
                model.SecondLastName = o.SecondLastName;
                model.EMail = o.EMail;
                model.GeoCityId = o.GeoCityId;
                model.BirthDateText= o.BirthDate.ToString("dd/MM/yyyy");
                model.GeoStateId = o.GeoCity.GeoStateId;
                model.GeoCountryId = o.GeoCity.GeoState.GeoCountryId;


            }
            else
            {
                model.Action = "-1";
                model.PatientId = -1;
                model.FirstName = string.Empty;
                model.FirstLastName = string.Empty;
                model.Gender = "M";
                model.BirthDate = DateTime.Now;
                model.Identification = string.Empty;
                model.IdentificationType = "-1";
                model.Address = string.Empty;
                model.Phone = string.Empty;
                model.Mobile = string.Empty;
                model.SecondName = string.Empty;
                model.SecondLastName = string.Empty;
                model.EMail = string.Empty;
                model.GeoCityId = "-1";
                model.BirthDateText = DateTime.Now.Date.ToString("dd/MM/yyyy");
                model.GeoStateId = "-1";
                model.GeoCountryId = "-1";


            }



            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Edit(PatientViewModel model)
        {

            model.Countries = HealthHelper.GetAllCountries();

            try
            {
                var svc = new PatientAppService();

                var o = new Patient
                {
                    PatientId = model.PatientId,
                    FirstName = model.FirstName,
                    FirstLastName = model.FirstLastName,
                    Gender = model.Gender,
                    BirthDate  = DateTime.ParseExact(model.BirthDateText, "dd/MM/yyyy", CultureInfo.InvariantCulture),
                    Identification = model.Identification,
                    IdentificationType = model.IdentificationType,
                    Address = model.Address,
                    Phone = model.Phone,
                    Mobile = model.Mobile,
                    SecondName = model.SecondName,
                    SecondLastName = model.SecondLastName,
                    EMail = model.EMail,
                    GeoCityId = model.GeoCityId

                };

                if (model.Action == "-1")
                {
                    var exist = svc.GetPatient(model.PatientId) != null;
                    if (!exist)
                    {
                        svc.AddPatient(o);
                        ViewBag.Feed = 0;
                    }
                    else
                    {
                        model.Action = "-1";
                        ViewBag.Feed = 3;
                        return View(model);
                    }
                }
                else
                {
                    o.PatientId = model.PatientId;
                    if (model.IsDeleteAction == 0)
                    {

                        svc.SavePatient(o);
                    }
                    else
                    {
                        svc.RemovePatient(model.PatientId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }