Example #1
0
        public void Edit(HairdresserService hairdresserService)
        {
            //1
            databaseContex.Entry(hairdresserService).State = EntityState.Modified;

            //2
            // databaseContex.Update(hairdresserService);
            databaseContex.SaveChanges();
        }
        public ActionResult Update(HairdresserServiceModel hairdresserServicemodel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Update", hairdresserServicemodel));
            }
            ;

            HairdresserService hairdresserService = new HairdresserService();
            var hairdresserServiceViewModel       = new HairdresserServiceListViewModel();

            hairdresserService.Id          = hairdresserServicemodel.Id.HasValue ? hairdresserServicemodel.Id.Value : 0;
            hairdresserService.Nameservice = hairdresserServicemodel.Nameservice;
            hairdresserService.Price       = hairdresserServicemodel.Price;
            serviceService.Edit(hairdresserService);

            return(RedirectToAction("Index"));
        }
        public ActionResult Create(HairdresserServiceModel hairdresserServicemodel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", hairdresserServicemodel));
            }
            ;

            HairdresserService hairdresserService = new HairdresserService();
            var hairdresserServiceViewModel       = new HairdresserServiceListViewModel();

            if (hairdresserServicemodel.Id != null)
            {
                Console.WriteLine("Error");
            }

            hairdresserService.Id          = hairdresserServicemodel.Id.HasValue ? hairdresserServicemodel.Id.Value : 0;
            hairdresserService.Nameservice = hairdresserServicemodel.Nameservice;
            hairdresserService.Price       = hairdresserServicemodel.Price;
            serviceService.Create(hairdresserService);

            return(RedirectToAction("Index"));
        }
Example #4
0
 public void Create(HairdresserService hairdresserService)
 {
     databaseContex.HairdresserServices.Add(hairdresserService);
     databaseContex.SaveChanges();
 }