Esempio n. 1
0
        public ActionResult Edit(int id, PublisherEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.PublisherId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreatePublisherService();

            if (service.UpdatePublisher(model))
            {
                TempData["SaveResult"] = "The publisher was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "The publisher could not be updated.");

            return(View(model));
        }
        public ActionResult Edit(int id)
        {
            //  var service = new PublisherService();
            var detail = _publisherService.GetPublisherById(id);
            var model  = new PublisherEdit()
            {
                PublisherId = detail.PublisherId,
                Name        = detail.Name,
                CompanySize = detail.CompanySize,
                Country     = detail.Country,
                Rating      = detail.Rating
            };

            return(View(model));
        }
Esempio n. 3
0
        public bool UpdatePublisher(PublisherEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx.Publishers
                    .Single(e => e.PublisherId == model.PublisherId);

                entity.PublisherId      = model.PublisherId;
                entity.PublisherName    = model.PublisherName;
                entity.Address          = model.Address;
                entity.PublisherWebsite = model.PublisherWebsite;

                return(ctx.SaveChanges() == 1);
            }
        }
Esempio n. 4
0
        public ActionResult Edit(int id)
        {
            var service = CreatePublisherService();
            var detail  = service.GetPublisherById(id);

            var model =
                new PublisherEdit
            {
                PublisherId      = detail.PublisherId,
                PublisherName    = detail.PublisherName,
                Address          = detail.Address,
                PublisherWebsite = detail.PublisherWebsite
            };

            return(View(model));
        }
 public bool UpdatePublisher(PublisherEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         try
         {
             var entity = ctx.Publishers.Single(e => e.Id == model.PublisherId);
             entity.Name        = model.Name;
             entity.CompanySize = model.CompanySize;
             entity.Country     = model.Country;
             entity.Rating      = model.Rating;
             entity.ModifiedUtc = DateTimeOffset.Now;
             return(ctx.SaveChanges() >= 1);
         }
         catch (Exception e)
         {
             Debug.Print("Exception thrown while looking for publisher");
             Debug.Print(e.Message);
             return(false);
         }
     }
 }
Esempio n. 6
0
        private void publisherEditBtn_Click(object sender, EventArgs e)
        {
            var publisherForm = new PublisherEdit();

            Nav(publisherForm, contentPanel);
        }