コード例 #1
0
        public ActionResult Edit(int id, ServiceViewModel service)
        {
            if (ModelState.IsValid)
            {
                var serviceModel = this.Data.Services.GetById(id);
                serviceModel.Type = service.Type;
                serviceModel.Price = service.Price;

                this.Data.Services.Update(serviceModel);
                this.Data.SaveChanges();

                this.Notify(GlobalConstants.EditService, NotificationType.success);

                return this.RedirectToAction("Details", "PriceList", new { id = serviceModel.PriceList.Id });
            }

            return this.View(service);
        }
コード例 #2
0
        public ActionResult Create(ServiceViewModel service, string priceListTitle)
        {
            if (ModelState.IsValid)
            {
                var serviceModel = Mapper.Map<NelitaBeautyStudio.Models.Service>(service);
                var priceList = this.Data.PriceLists.All().FirstOrDefault(p => p.Title == priceListTitle);

                serviceModel.PriceList = priceList;

                this.Data.Services.Add(serviceModel);
                this.Data.SaveChanges();

                this.Notify(GlobalConstants.AddService, NotificationType.success);

                return this.RedirectToAction("Details", "PriceList", new { id = priceList.Id });
            }

            return this.View(service);
        }