Example #1
0
        public ActionResult Create(ServiceItem model)
        {
            try
            {
                var service = _repository.GetService(model.ServiceId);
                var serviceItem = new ServiceItem
                {
                    Service = service,
                    Title = model.Title,
                    TitleEng = model.TitleEng,
                    Description = model.Description,
                    DescriptionEng = model.DescriptionEng,
                    SortOrder = model.SortOrder,
                    Price = model.Price
                };
                _repository.AddServiceItem(serviceItem);
            }
            catch (Exception ex)
            {
                TempData["errorMessage"] = ex.Message + (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message) ? ex.InnerException.Message : "");
                return View(model);
            }

            return RedirectToAction("Index", "Service");
        }
Example #2
0
 public ActionResult Edit(ServiceItem model)
 {
     try
     {
         var service = _repository.GetServiceItem(model.Id);
         TryUpdateModel(service, new[] { "Title", "TitleEng", "Description", "DescriptionEng", "SortOrder", "Price" });
         _repository.SaveServiceItem(service);
     }
     catch (Exception ex)
     {
         TempData["errorMessage"] = ex.Message;
         return View(model);
     }
     return RedirectToAction("Index","Service");
 }
Example #3
0
 public int AddServiceItem(ServiceItem serviceItem)
 {
     _store.ServiceItems.Add(serviceItem);
     _store.SaveChanges();
     return serviceItem.Id;
 }
Example #4
0
 public void SaveServiceItem(ServiceItem serviceItem)
 {
     _store.SaveChanges();
 }