public ActionResult DeleteConfirmed(int id)
        {
            ServicePart servicepart = db.ServiceParts.Find(id);

            db.ServiceParts.Remove(servicepart);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 private static void DisplayServicePart(ServicePart servicePart)
 {
     Console.WriteLine($"\t\t\tPart ID:          {Formatters.FormatId(servicePart.Part.Id)}" +
                       $"\n\t\t\tSupplier Part ID: {servicePart.Part.SupplierPartNumber}" +
                       $"\n\t\t\tPart Name:        {servicePart.Part.PartName} " +
                       $"\n\t\t\tPrice per Unit:   £{Formatters.FormatPrice(servicePart.Part.Price)} " +
                       $"\n\t\t\tQuantity:         {servicePart.Quantity}\n");
 }
        //
        // GET: /ServicePart/Details/5

        public ActionResult Details(int id = 0)
        {
            ServicePart servicepart = db.ServiceParts.Find(id);

            if (servicepart == null)
            {
                return(HttpNotFound());
            }
            return(View(servicepart));
        }
        //
        // GET: /ServicePart/Edit/5

        public ActionResult Edit(int id = 0)
        {
            ServicePart servicepart = db.ServiceParts.Find(id);

            if (servicepart == null)
            {
                return(HttpNotFound());
            }
            ViewBag.partId    = new SelectList(db.Parts, "partId", "partName", servicepart.partId);
            ViewBag.statusId  = new SelectList(db.Catalogs, "catalogId", "catalogValue", servicepart.statusId);
            ViewBag.serviceId = new SelectList(db.Services, "serviceId", "serviceDescription", servicepart.serviceId);
            return(View(servicepart));
        }
 public ActionResult Edit(ServicePart servicepart)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicepart).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.partId    = new SelectList(db.Parts, "partId", "partName", servicepart.partId);
     ViewBag.statusId  = new SelectList(db.Catalogs, "catalogId", "catalogValue", servicepart.statusId);
     ViewBag.serviceId = new SelectList(db.Services, "serviceId", "serviceDescription", servicepart.serviceId);
     return(View(servicepart));
 }
Ejemplo n.º 6
0
        public ActionResult CreateServicePost(ServiceViewModel model)
        {
            if (!this.services.Authorizer.Authorize(Permissions.BasicDataPermission))
            {
                return(new HttpUnauthorizedResult());
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View("CreateService", model));
            }

            var service = this.services.ContentManager.New("Service");

            this.services.ContentManager.Create(service);
            ServicePart part = service.As <ServicePart>();

            part.Name        = model.Name;
            part.Description = model.Description;
            this.services.ContentManager.Publish(service);
            this.basicDataService.ClearCache();

            return(RedirectToAction("Services"));
        }