Esempio n. 1
0
        public ActionResult Edit(int id)
        {
            TreatmentEditItem treatmentItem = new TreatmentEditItem();

            if (id != 0)
            {
                var treatment = Manager.GetById(id);
                if (treatment != null)
                {
                    treatmentItem.Id                  = treatment.Id;
                    treatmentItem.Name                = treatment.Name;
                    treatmentItem.Description         = treatment.Description;
                    treatmentItem.PictureUrl          = treatment.PictureUrl;
                    treatmentItem.Price               = treatment.Price;
                    treatmentItem.TreatmentCategoryId = treatment.TreatmentCategoryId;
                    treatmentItem.IsActive            = treatment.IsActive;
                    treatmentItem.DurationId          = treatment.DurationId.HasValue?(ETreatmentDuration)Enum.ToObject(typeof(ETreatmentDuration), treatment.DurationId.Value):ETreatmentDuration.Sixty;
                }
            }
            else
            {
                treatmentItem.DurationId = ETreatmentDuration.Sixty;
            }

            treatmentItem.TreatmentCategoryList = GetTreatmentCategoryList();
            treatmentItem.HasBookings           = Manager.HasBookings(id);

            return(View("TreatmentEditView", treatmentItem));
        }