Пример #1
0
        public IActionResult Company(string name)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (name == "")
            {
                return(RedirectToAction("index"));
            }

            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            ClientAddress   boo     = context.GetClientAddressList(name);

            if (boo.ClientCompany == "" || boo.ClientCompany == null)
            {
                //what happen when company do not have an address yet?
                Debug.WriteLine("This is not good");
                return(RedirectToAction("index"));
            }
            else
            {
                ViewData["CompanyName"] = boo.ClientCompany;
                if (boo.Addresslist != null)
                {
                    Debug.WriteLine("how the fk is this initialize?" + boo.Addresslist.Count());
                    ViewData["AddressList"] = boo.Addresslist;
                }
            }

            TempData["companyname"] = boo.ClientCompany;
            return(View());
        }
Пример #2
0
        public ActionResult AddAddress()
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }

            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin"))
            {
                return(RedirectToAction("Error", "Admin"));
            }

            string          name    = TempData.Peek("companyname").ToString();
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            ClientAddress   cA      = context.GetClientAddressList(name);

            if (cA.Addresslist == null)
            {
                TempData["Message"] = " false";
            }
            else if (cA.Addresslist.Count() > 0 && cA.Addresslist.Count() < 5)
            {
                TempData["Message"] = "false";
            }
            else if (context.GetClientAddressList(name).Addresslist.Count() == 5)
            {
                TempData["Message"] = "true";
                //return RedirectToAction("company", new { name = name });
            }

            ClientAddress Weeeheee = new ClientAddress {
                ClientCompany = name
            };

            return(PartialView("AddAddress", Weeeheee));
        }
Пример #3
0
        public IActionResult ChangeAddressInput()
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }

            string name = "";

            if (((TempData.Peek("dataishere") != null).ToString().ToLower()) == "true")
            {
                name = TempData.Peek("dataishere").ToString();
            }

            if (name == "" || name == null)
            {
                return(View());
            }
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            ClientAddress   cA      = context.GetClientAddressList(name);
            List <string>   aList   = new List <string>();

            aList = cA.Addresslist;

            if (aList == null || aList.Count() == 0)
            {
            }
            else
            {
                List <SelectListItem> AddressList = new List <SelectListItem>();
                for (int i = 0; i < aList.Count(); i++)
                {
                    AddressList.Add(new SelectListItem {
                        Value = aList[i], Text = aList[i]
                    });
                }
                ViewData["AddressList"] = AddressList;
            }
            Debug.WriteLine(Url.Action("ChangeAddressInput", "ServiceReport"));
            Debug.WriteLine("muahaahahah pelase?");
            return(PartialView("ChangeAddressInput", new ServiceReport()));
        }
Пример #4
0
        public IActionResult AddNewCompany(ClientAddress clientAddress)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin"))
            {
                return(RedirectToAction("Error", "Admin"));
            }
            if (!ModelState.IsValid)
            {
                if (clientAddress.ClientCompany == "")
                {
                    ModelState.AddModelError("", "Please enter a company name");
                }
                else if (clientAddress.Address == "")
                {
                    ModelState.AddModelError("", "Please enter a Address");
                }

                return(View(clientAddress));
            }
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;

            ClientAddress exister = context.GetClientAddressList(clientAddress.ClientCompany);

            if (exister.ClientCompany != "")
            {
                ModelState.AddModelError("", "The company already exists.");
                return(View(clientAddress));
            }

            context.LogAction("Client", clientAddress.ClientCompany + " has been added to the client list with this address (" + clientAddress.Address + ")", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))));
            context.AddNewCompany(clientAddress);
            return(RedirectToAction("Company", new { name = clientAddress.ClientCompany }));
        }
Пример #5
0
        public IActionResult AddNewReport(ServiceReport model)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }


            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;

            ViewData["Companies"] = context.GetClientByContract();

            #region prepare for failure codes
            List <SelectListItem> PurposeList = new List <SelectListItem>();
            PurposeList.Add(new SelectListItem {
                Value = "Project", Text = "Project"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Installation", Text = "Installation"
            });
            PurposeList.Add(new SelectListItem {
                Value = "M.S.A", Text = "M.S.A"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Chargable", Text = "Chargable"
            });
            PurposeList.Add(new SelectListItem {
                Value = "P.O.C", Text = "P.O.C"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Delivery", Text = "Delivery"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Return", Text = "Return"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Others", Text = "Others"
            });
            ViewData["Purpose"] = PurposeList;

            List <SelectListItem> JobStatusList = new List <SelectListItem>();
            JobStatusList.Add(new SelectListItem {
                Value = "Completed", Text = "Completed"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Followup Required", Text = "Followup Required"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Recommendation Requied", Text = "Recommendation Required"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Escalated to Ext. Support", Text = "Escalated to Ext. Support"
            });
            ViewData["JobStatusList"] = JobStatusList;

            model.SerialNumber = context.getReportCounts() + 1;
            string name = "";
            if (((TempData.Peek("dataishere") != null).ToString().ToLower()) == "true")
            {
                name = TempData.Peek("dataishere").ToString();
            }

            if (name != "")
            {
                ClientAddress         cA          = context.GetClientAddressList(name);
                List <string>         aList       = cA.Addresslist;
                List <SelectListItem> AddressList = new List <SelectListItem>();
                if (aList != null)
                {
                    for (int i = 0; i < aList.Count(); i++)
                    {
                        AddressList.Add(new SelectListItem {
                            Value = aList[i], Text = aList[i]
                        });
                    }
                }
                ViewData["AddressList"] = AddressList;
            }
            else
            {
                ModelState.AddModelError("", "A error occured. Important");
                return(View(model));
            }
            #endregion
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (ModelState.IsValid)
            {
                double totalmshremain  = context.GetRemainingMSHByCompany(model);
                double calculatedhours = context.CalculateMSH(model.TimeStart, model.TimeEnd);
                //for test purpose
                //ModelState.AddModelError("", "The calculated MSH:" + calculatedhours);
                //return View(model);
                if (totalmshremain < calculatedhours)
                {
                    ModelState.AddModelError("", "The company you have selected does not have enough remaining MSH, Please contact your Boss immediately regarding this issue.");
                    return(View(model));
                }
                if (context.CheckExisitingReportID(model.SerialNumber))
                {
                    ModelState.AddModelError("", "Contact Application Developer");
                    return(View(model));
                }

                if (model.TimeStart > DateTime.Now || model.TimeEnd > DateTime.Now)
                {
                    ModelState.AddModelError("", "Please enter a report after the service is rendered");
                    return(View(model));
                }

                if (!(model.TimeStart.CompareTo(model.TimeEnd) <= 0))
                {
                    ModelState.AddModelError("", "your start time should be before your end time");
                    return(View(model));
                }
                User user = context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID")));
                model.ReportFrom = user.FirstName + user.LastName;
                context.AddServiceReport(model);
                context.LogAction("Service Report", "Service Report (SRN: " + model.SerialNumber + ") created for " + model.ClientCompanyName + " at " + model.ClientAddress + ".", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))));
                TempData.Remove("dataishere");
                return(RedirectToAction("ViewReports", "ServiceReport"));
            }

            return(View(model));
        }