Ejemplo n.º 1
0
 public PointOfContactModel(PointOfContact entity)
 {
     FirstName    = entity.FirstName;
     LastName     = entity.LastName;
     Title        = entity.Title;
     Address      = new SystemAddressModel(entity.Address);
     PhoneNumber  = new SystemPhoneNumberModel(entity.PhoneNumber);
     EmailAddress = new SystemEmailAddressModel(entity.EmailAddress);
 }
        public ActionResult Details(string id)
        {
            if (id == "")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PointOfContact pointOfContact = db.PointOfContacts.Find(id);

            if (pointOfContact == null)
            {
                return(HttpNotFound());
            }
            return(View(pointOfContact));
        }
        public ActionResult DeleteConfirmed(string id)
        {
            PointOfContact pointOfContact = db.PointOfContacts.Find(id);

            db.PointOfContacts.Remove(pointOfContact);
            try
            {
                db.SaveChanges();
                TempData["SuccessOHMsg"] = "Point of Contact " + pointOfContact.POCName + " deleted";
                return(RedirectToAction("Index"));
            }
            catch
            {
                TempData["DangerOHMsg"] = "Problem deleting the Point of Contact " + pointOfContact.POCName;
                return(RedirectToAction("Index"));
            }
        }
 public ActionResult Edit([Bind(Include = "POCName,Notes")] PointOfContact pointOfContact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pointOfContact).State = EntityState.Modified;
         try
         {
             db.SaveChanges();
             TempData["SuccessOHMsg"] = "Point of Contact " + pointOfContact.POCName + " edited";
             return(RedirectToAction("Index"));
         }
         catch
         {
             TempData["DangerOHMsg"] = "Problem editing the Point of Contact " + pointOfContact.POCName;
             return(RedirectToAction("Index"));
         }
     }
     return(View(pointOfContact));
 }
        public ActionResult Create([Bind(Include = "POCName,Notes")] PointOfContact pointOfContact)
        {
            if (ModelState.IsValid)
            {
                db.PointOfContacts.Add(pointOfContact);
                try
                {
                    db.SaveChanges();
                    TempData["SuccessOHMsg"] = "Point of Contact " + pointOfContact.POCName + " created";
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    TempData["DangerOHMsg"] = "Problem creating the Point of Contact " + pointOfContact.POCName;
                    return(RedirectToAction("Index"));
                }
            }

            return(View(pointOfContact));
        }
Ejemplo n.º 6
0
 public bool IsHalfDistance()
 {
     return(string.IsNullOrWhiteSpace(PointOfContact) ? false : PointOfContact.ToLower() == "half-distance");
 }
Ejemplo n.º 7
0
 public bool IsAtTheTable()
 {
     return(string.IsNullOrWhiteSpace(PointOfContact) ? false : PointOfContact.ToLower() == "behind");
 }
Ejemplo n.º 8
0
        public ActionResult HelpDeskForm([Bind(Include = "SDReqID,VIPID,LicenseTypeID,ProductID,POCName,POCNotes,Qty")] HelpDeskFormViewModel helpDeskForm)
        {
            ViewBag.VIPList         = new SelectList(db.VIPs.OrderBy(x => x.VIPID), "VIPID", "VIPName");
            ViewBag.LicenseTypeList = new SelectList(db.LicenseTypes.OrderBy(x => x.LicenseTypeID), "LicenseTypeID", "LicenseTypeDesc");
            ViewBag.ProductList     = new SelectList(db.Products.OrderBy(x => x.ProductID), "ProductID", "ProductDesc");

            if (ModelState.IsValid)
            {
                // ServiceDesk Request ID should not exist already
                if (db.ServiceDeskRequests.Any(o => o.ServiceDeskRequestID == helpDeskForm.SDReqID))
                {
                    ModelState.AddModelError("", "ServiceDesk Request ID exists already.");
                    return(View());
                }

                // If Point of Contact doesn't already exist, create it.
                PointOfContact poc;
                if (!db.PointOfContacts.Any(o => o.POCName == helpDeskForm.POCName))
                {
                    poc         = new PointOfContact();
                    poc.POCName = helpDeskForm.POCName;
                    poc.Notes   = helpDeskForm.POCNotes;
                    db.PointOfContacts.Add(poc);
                    db.SaveChanges();
                    TempData["SuccessOHMsg"] = "Point of Contact " + poc.POCName + " created";
                }
                else
                {
                    poc = db.PointOfContacts.Find(helpDeskForm.POCName);
                }

                // Get objects from tables
                VIP         vip         = db.VIPs.Find(helpDeskForm.VIPID);
                LicenseType licenseType = db.LicenseTypes.Find(helpDeskForm.LicenseTypeID);
                Product     product     = db.Products.Find(helpDeskForm.ProductID);

                // Create new ServiceDesk Request
                ServiceDeskRequest sdReq = new ServiceDeskRequest();
                sdReq.ServiceDeskRequestID = helpDeskForm.SDReqID;

                // Create new Purchase Order
                PurchaseOrder po = new PurchaseOrder();
                po.Qty    = helpDeskForm.Qty;
                po.PODate = new DateTime(1753, 1, 1);       // Minimum date for SQL

                // Create new Request
                Request req = new Request();
                req.PurchaseOrder  = po;
                req.VIP            = vip;
                req.LicenseType    = licenseType;
                req.Product        = product;
                req.PointOfContact = poc;

                // Add Request to other models' virtual or ICollection
                sdReq.Request = req;
                po.Request    = req;
                po.RequestID  = req.RequestID;
                poc.Requests.Add(req);
                vip.Requests.Add(req);
                licenseType.Requests.Add(req);
                product.Requests.Add(req);

                // Add new records to database tables
                db.Requests.Add(req);   // Also adds Purchase Orders to table because of 1 to 1 relationship
                db.SaveChanges();
                db.ServiceDeskRequests.Add(sdReq);
                db.SaveChanges();
                TempData["SuccessOHMsg"] = "ServiceDesk Request " + sdReq.ServiceDeskRequestID + ", Purchase Order " + po.PurchaseOrderID + ", and Request " + req.RequestID + " created";
                return(RedirectToAction("HelpDeskForm"));
            }

            ModelState.AddModelError("", "Problem Submitting the form. Model state is not valid.");
            return(View());
        }
Ejemplo n.º 9
0
        public ActionResult Edit([Bind(Include = "RequestID,PurchaseOrderID,VIPID,LicenseTypeID,ProductID,POCName")] RequestEditViewModel reqEdit)
        {
            if (ModelState.IsValid)
            {
                Request req = db.Requests.Find(reqEdit.RequestID);

                // If there is a difference in the VIPs
                if (req.VIP.VIPID != reqEdit.VIPID)
                {
                    // Assumes that the VIP already exists because it came from a drop down list
                    VIP vip = db.VIPs.Find(reqEdit.VIPID);

                    // Remove request from old VIP
                    req.VIP.Requests.Remove(req);

                    // Add request to new VIP
                    vip.Requests.Add(req);

                    // Point the request to the new VIP
                    req.VIP = vip;
                }

                // If there is a difference in the LicenseTypes
                if (req.LicenseType.LicenseTypeID != reqEdit.LicenseTypeID)
                {
                    // Assumes that the LicenseType already exists because it came from a drop down list
                    LicenseType licenseType = db.LicenseTypes.Find(reqEdit.LicenseTypeID);

                    // Remove request from old VIP
                    req.LicenseType.Requests.Remove(req);

                    // Add request to new VIP
                    licenseType.Requests.Add(req);

                    // Point the request to the new VIP
                    req.LicenseType = licenseType;
                }

                // If there is a difference in the Products
                if (req.Product.ProductID != reqEdit.ProductID)
                {
                    // Assumes that the VIP already exists because it came from a drop down list
                    Product product = db.Products.Find(reqEdit.ProductID);

                    // Remove request from old VIP
                    req.Product.Requests.Remove(req);

                    // Add request to new VIP
                    product.Requests.Add(req);

                    // Point the request to the new VIP
                    req.Product = product;
                }

                // If there is a difference in the Point of Contacts
                if (req.PointOfContact.POCName != reqEdit.POCName)
                {
                    // Assumes that the VIP already exists because it came from a drop down list
                    //VIP vip = db.VIPs.Find(reqEdit.VIPID);

                    PointOfContact poc;

                    // If the Point of Contact already exists
                    if (db.PointOfContacts.Any(o => o.POCName == reqEdit.POCName))
                    {
                        poc = db.PointOfContacts.Find(reqEdit.POCName);
                    }
                    else
                    {
                        // Create new Point of Contact
                        poc         = new PointOfContact();
                        poc.POCName = reqEdit.POCName;
                    }

                    // Remove request from old Point of Contact
                    req.PointOfContact.Requests.Remove(req);

                    // Add request to new Point of Contact
                    poc.Requests.Add(req);

                    // Point the request to the new Point of Contact
                    req.PointOfContact = poc;
                }

                db.Entry(req).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                    TempData["SuccessOHMsg"] = "Request " + req.RequestID + " edited";
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    TempData["DangerOHMsg"] = "Problem editing the Request " + req.RequestID;
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.VIPList         = new SelectList(db.VIPs.OrderBy(x => x.VIPID), "VIPID", "VIPName");
            ViewBag.LicenseTypeList = new SelectList(db.LicenseTypes.OrderBy(x => x.LicenseTypeID), "LicenseTypeID", "LicenseTypeDesc");
            ViewBag.ProductList     = new SelectList(db.Products.OrderBy(x => x.ProductID), "ProductID", "ProductDesc");

            return(View(reqEdit));
        }