Exemplo n.º 1
0
        public ActionResult AskQuery(string complaintid)
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                if (Session["LoginType"].Equals("Worker") && Session["Id"] != null)
                {
                    string cid = complaintid;
                    string sid = Session["Id"].ToString();

                    var comobj = (from c in db.tblComplaints
                                  where (c.ComplaintId.ToString().Equals(cid) && c.ComplaintStatus.Equals("Assigned") && c.WorkerId.ToString().Equals(sid))
                                  select c).FirstOrDefault();
                    if (comobj == null)
                    {
                        return(RedirectToAction("Home", "Worker"));
                    }
                    else
                    {
                        return(View(comobj));
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Feedback(tblComplaint comobj)
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                if (Session["LoginType"].Equals("Customer") && Session["Id"] != null)
                {
                    var obj = (from c in db.tblComplaints
                               where c.ComplaintId.Equals(comobj.ComplaintId)
                               select c).FirstOrDefault();

                    obj.ComplaintStatus = "Feedback Provided";
                    obj.Feedback        = comobj.Feedback;
                    db.SaveChanges();
                    return(RedirectToAction("Home", "Customer"));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult Close(string complaintid)
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                if (Session["LoginType"].Equals("ProductAdmin") && Session["Id"] != null)
                {
                    int cid = int.Parse(complaintid);

                    var comobj = (from c in db.tblComplaints
                                  where c.ComplaintId.Equals(cid)
                                  select c).FirstOrDefault();

                    comobj.ComplaintStatus = "Closed";
                    db.SaveChanges();

                    return(RedirectToAction("Home", "ProductAdmin"));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
Exemplo n.º 4
0
        public ActionResult AskQuery(tblComplaint comobj)
        {
            try
            {
                if (Session["LoginType"].Equals("Worker") && Session["Id"] != null)
                {
                    dbCMSEntities db = new dbCMSEntities();

                    var obj = (from c in db.tblComplaints
                               where c.ComplaintId.Equals(comobj.ComplaintId)
                               select c).FirstOrDefault();

                    obj.WorkerQuery   = comobj.WorkerQuery;
                    obj.CustomerReply = "Awaiting Reply";
                    db.SaveChanges();
                    return(RedirectToAction("Home", "Worker"));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult Assign(int complaintid)
        {
            try
            {
                dbCMSEntities db = new dbCMSEntities();

                string sid = Session["Id"].ToString();
                Session["complaintid"] = complaintid;

                var comp = (from p in db.tblComplaints
                            where p.ComplaintId.Equals(complaintid) && (p.ComplaintStatus.Equals("Not Assigned") | p.ComplaintStatus.Equals("Feedback Provided"))
                            select p).FirstOrDefault();

                string pid = comp.ProductId.ToString();

                var prodadmin = (from p in db.tblProducts
                                 where p.ProductId.ToString().Equals(pid) && p.ProductAdminId.ToString().Equals(sid)
                                 select p).FirstOrDefault();

                var worker = from w in db.tblWorkers
                             where w.ProductAdminId.ToString().Equals(sid)
                             select w;
                return(View(worker));
            }

            catch (Exception)
            {
                return(RedirectToAction("Home", "ProductAdmin"));
            }
        }
Exemplo n.º 6
0
        public ActionResult Reply(string complaintid)
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                if (Session["LoginType"].Equals("Customer") && Session["Id"] != null)
                {
                    string cid        = complaintid;
                    string customerid = Session["Id"].ToString();

                    var comobj = (from c in db.tblComplaints
                                  where c.ComplaintId.ToString().Equals(cid) && c.CustomerId.ToString().Equals(customerid)
                                  select c).FirstOrDefault();

                    if (comobj.CustomerReply == "Awaiting Reply")
                    {
                        return(View(comobj));
                    }
                    else
                    {
                        return(RedirectToAction("Login", "Login"));
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
Exemplo n.º 7
0
 public ActionResult NewComplaint(tblComplaint compobj)
 {
     try
     {
         if (Session["LoginType"].Equals("Customer") && Session["Id"] != null)
         {
             dbCMSEntities db = new dbCMSEntities();
             compobj.CustomerId      = int.Parse(Session["Id"].ToString());
             compobj.ComplaintStatus = "Not Assigned";
             compobj.WorkerQuery     = "NA";
             compobj.CustomerReply   = "NA";
             compobj.Feedback        = "NA";
             compobj.ComplaintDate   = DateTime.Now;
             db.tblComplaints.Add(compobj);
             db.SaveChanges();
             return(RedirectToAction("Home", "Customer"));
         }
         else
         {
             return(RedirectToAction("Login", "Login"));
         }
     }
     catch (Exception)
     {
         return(RedirectToAction("Error", "Home"));
     }
 }
Exemplo n.º 8
0
        public ActionResult Home()
        {
            try
            {
                if (Session["LoginType"].Equals("Worker") && Session["Id"] != null)
                {
                    dbCMSEntities db        = new dbCMSEntities();
                    string        sessionid = Session["Id"].ToString();
                    var           worker    = (from work in db.tblWorkers
                                               where work.WorkerId.ToString().Equals(sessionid)
                                               select work).FirstOrDefault();

                    var complaintdata = from comp in db.tblComplaints
                                        where comp.WorkerId.ToString().Equals(sessionid)
                                        select comp;

                    WorkerView wv = new WorkerView {
                        Workerdata = worker, Complaintdata = complaintdata
                    };

                    return(View(wv));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
Exemplo n.º 9
0
        public ActionResult Home()
        {
            try
            {
                if (Session["LoginType"].Equals("Customer") && Session["Id"] != null)
                {
                    dbCMSEntities db        = new dbCMSEntities();
                    string        sessionid = Session["Id"].ToString();
                    var           customer  = (from cus in db.tblCustomers
                                               where cus.CustomerId.ToString().Equals(sessionid)
                                               select cus).FirstOrDefault();

                    var complaint = (from com in db.tblComplaints
                                     where com.CustomerId.ToString().Equals(sessionid)
                                     select com);

                    CustomerView custview = new CustomerView()
                    {
                        Customerdata = customer, Complaintdata = complaint
                    };

                    return(View(custview));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult Assign(string WorkerId)
        {
            if (Session["LoginType"].Equals("ProductAdmin") && Session["Id"] != null)
            {
                string        paid = Session["Id"].ToString();
                string        cid  = Session["complaintid"].ToString();
                dbCMSEntities db   = new dbCMSEntities();

                try
                {
                    var worker = (from w in db.tblWorkers
                                  where w.WorkerId.ToString().Equals(WorkerId)
                                  select w).FirstOrDefault();

                    if (worker.ProductAdminId.ToString() != Session["Id"].ToString())
                    {
                        ModelState.AddModelError("Error", "Invalid Worker Id");
                        var workernew = from w in db.tblWorkers
                                        where w.ProductAdminId.ToString().Equals(paid)
                                        select w;
                        return(View(workernew));
                    }

                    var comp = (from i in db.tblComplaints
                                where i.ComplaintId.ToString().Equals(cid)
                                select i).FirstOrDefault();
                    comp.WorkerId        = worker.WorkerId;
                    comp.ComplaintStatus = "Assigned";
                    worker.NoOfCases     = worker.NoOfCases + 1;
                    worker.CurrentStatus = "Working";
                    db.SaveChanges();
                    return(RedirectToAction("Home", "ProductAdmin"));
                }
                catch (System.NullReferenceException)
                {
                    ModelState.AddModelError("Error", "Invalid Worker Id");
                    var worker = from w in db.tblWorkers
                                 where w.ProductAdminId.ToString().Equals(paid)
                                 select w;
                    return(View(worker));
                }
                catch (System.InvalidOperationException)
                {
                    ModelState.AddModelError("Error", "Invalid Worker Id");
                    var worker = from w in db.tblWorkers
                                 where w.ProductAdminId.ToString().Equals(paid)
                                 select w;
                    return(View(worker));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
        public ActionResult SignUp(tblCustomer obj)
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                db.tblCustomers.Add(obj);
                db.SaveChanges();
                return(RedirectToAction("Successful", "Home"));
            }
            catch (Exception)
            {
                ModelState.AddModelError("Error", "Email or Account Number already registered");
                return(View());
            }
        }
Exemplo n.º 12
0
        public ActionResult Resolved(string complaintid)
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                if (Session["LoginType"].Equals("Worker") && Session["Id"] != null)
                {
                    int    cid = int.Parse(complaintid);
                    string wid = Session["Id"].ToString();

                    var comobj = (from c in db.tblComplaints
                                  where c.ComplaintId.Equals(cid)
                                  select c).FirstOrDefault();

                    comobj.ComplaintStatus = "Resolved";
                    comobj.WorkerQuery     = "NA";
                    comobj.CustomerReply   = "NA";

                    var worker = (from w in db.tblWorkers
                                  where w.WorkerId.ToString().Equals(wid)
                                  select w).FirstOrDefault();

                    if (worker.NoOfCases == 1)
                    {
                        worker.CurrentStatus = "Free";
                    }

                    worker.NoOfCases = worker.NoOfCases - 1;

                    db.SaveChanges();

                    return(RedirectToAction("Home", "Worker"));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult Home()
        {
            try
            {
                if (Session["LoginType"].Equals("ProductAdmin") && Session["Id"] != null)
                {
                    dbCMSEntities db        = new dbCMSEntities();
                    string        sessionid = Session["Id"].ToString();

                    var productadmin = (from proda in db.tblProductAdmins
                                        where proda.ProductAdminId.ToString().Equals(sessionid)
                                        select proda).FirstOrDefault();

                    string paid = productadmin.ProductAdminId.ToString();

                    var productdata = (from p in db.tblProducts
                                       where p.ProductAdminId.ToString().Equals(paid)
                                       select p).FirstOrDefault();

                    string pid = productdata.ProductId.ToString();

                    var complaintdata = from p in db.tblComplaints
                                        where p.ProductId.ToString().Equals(pid)
                                        select p;

                    ProductAdminView pav = new ProductAdminView {
                        ProductAdmindata = productadmin, Complaintdata = complaintdata
                    };

                    return(View(pav));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }

            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult ForgotPassword(tblCustomer obj)
        {
            string accno = obj.AccountNumber;
            string email = obj.Email;

            dbCMSEntities db = new dbCMSEntities();

            var customer = (from c in db.tblCustomers
                            where c.AccountNumber.Equals(accno) && c.Email.Equals(email)
                            select c).FirstOrDefault();

            if (customer == null)
            {
                ModelState.AddModelError("Error", "Invalid Email or Account Number");
                return(View());
            }

            Session["ResetId"] = customer.CustomerId;
            return(RedirectToAction("ResetPassword"));
        }
Exemplo n.º 15
0
        public ActionResult Home()
        {
            try
            {
                if (Session["LoginType"].Equals("SystemAdmin") && Session["Id"] != null)
                {
                    dbCMSEntities db          = new dbCMSEntities();
                    string        sessionid   = Session["Id"].ToString();
                    var           systemadmin = (from sysa in db.tblSystemAdmins
                                                 where sysa.SystemAdminId.ToString().Equals(sessionid)
                                                 select sysa).FirstOrDefault();

                    var compdata = from c in db.tblComplaints
                                   select c;

                    var worker = from w in db.tblWorkers
                                 select w;

                    var prodadmin = from p in db.tblProductAdmins
                                    select p;

                    var customer = from c in db.tblCustomers
                                   select c;

                    SystemAdminView sav = new SystemAdminView()
                    {
                        complaintdata = compdata, workerdata = worker, productadmindata = prodadmin, systemadmindata = systemadmin, customerdata = customer
                    };

                    return(View(sav));
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult ResetPassword()
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                string sessionid = Session["ResetId"].ToString();
                var    customer  = (from c in db.tblCustomers
                                    where c.CustomerId.ToString().Equals(sessionid)
                                    select c).First();

                customer.SecurityAnswer = null;
                customer.Pssd           = null;

                return(View(customer));
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
Exemplo n.º 17
0
 public ActionResult Delete(string complaintid)
 {
     try
     {
         if (Session["LoginType"].Equals("SystemAdmin") && Session["Id"] != null)
         {
             dbCMSEntities db             = new dbCMSEntities();
             var           complainttable = (from i in db.tblComplaints
                                             where i.ComplaintId.ToString().Equals(complaintid) && i.ComplaintStatus.Equals("Closed")
                                             select i).FirstOrDefault();
             db.tblComplaints.Remove(complainttable);
             db.SaveChanges();
             return(RedirectToAction("Home", "SystemAdmin"));
         }
     }
     catch (Exception)
     {
         return(RedirectToAction("Error", "Home"));
     }
     return(RedirectToAction("Error", "Home"));
 }
        public ActionResult ResetPassword(tblCustomer obj)
        {
            dbCMSEntities db = new dbCMSEntities();

            try
            {
                string sessionid = Session["ResetId"].ToString();
                string answer    = obj.SecurityAnswer;


                var customer = (from c in db.tblCustomers
                                where c.CustomerId.ToString().Equals(sessionid) && c.SecurityAnswer.Equals(answer)
                                select c).FirstOrDefault();

                if (customer == null)
                {
                    ModelState.AddModelError("Error", "Incorrect security answer");

                    var customernew = (from a in db.tblCustomers
                                       where a.CustomerId.ToString().Equals(sessionid)
                                       select a).First();
                    customernew.SecurityAnswer = null;
                    customernew.Pssd           = null;

                    return(View(customernew));
                }

                customer.ConPssd = obj.ConPssd;
                customer.Pssd    = obj.Pssd;
                db.SaveChanges();

                return(RedirectToAction("SuccessfulReset", "Login"));
            }

            catch (Exception)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
Exemplo n.º 19
0
        public ActionResult ChangePassword(Login credentials)
        {
            dbCMSEntities dbo = new dbCMSEntities();

            string Pssd      = credentials.Pssd;
            string LoginType = Session["LoginType"].ToString();
            string NewPssd   = credentials.NewPssd;
            int    uid       = int.Parse(Session["Id"].ToString());


            if (LoginType == "SystemAdmin")
            {
                var user = (from u in dbo.tblSystemAdmins
                            where u.SystemAdminId.Equals(uid) && u.Pssd.Equals(Pssd)
                            select u).FirstOrDefault();

                try
                {
                    if (user.Pssd == Pssd)
                    {
                        if (Pssd == NewPssd)
                        {
                            ModelState.AddModelError("Error", "Old and New Password cannot be the same");
                            return(View());
                        }
                        user.Pssd = NewPssd;
                        dbo.SaveChanges();
                        return(RedirectToAction("Login", "Login"));
                    }
                }
                catch (Exception)
                {
                    ModelState.AddModelError("Error", "Invalid Old Password");
                    return(View());
                }
            }

            else if (LoginType == "ProductAdmin")
            {
                var user = (from u in dbo.tblProductAdmins
                            where u.ProductAdminId.Equals(uid) && u.Pssd.Equals(Pssd)
                            select u).FirstOrDefault();

                try
                {
                    if (user.Pssd == Pssd)
                    {
                        if (Pssd == NewPssd)
                        {
                            ModelState.AddModelError("Error", "Old and New Password cannot be the same");
                            return(View());
                        }
                        user.Pssd = NewPssd;
                        dbo.SaveChanges();
                        return(RedirectToAction("Login", "Login"));
                    }
                }

                catch (Exception)
                {
                    ModelState.AddModelError("Error", "Invalid Old Password");
                    return(View());
                }
            }

            else if (LoginType == "Worker")
            {
                var user = (from u in dbo.tblWorkers
                            where u.WorkerId.Equals(uid) && u.Pssd.Equals(Pssd)
                            select u).FirstOrDefault();
                try
                {
                    if (user.Pssd == Pssd)
                    {
                        if (Pssd == NewPssd)
                        {
                            ModelState.AddModelError("Error", "Old and New Password cannot be the same");
                            return(View());
                        }
                        user.Pssd = NewPssd;
                        dbo.SaveChanges();
                        return(RedirectToAction("Login", "Login"));
                    }
                }

                catch (Exception)
                {
                    ModelState.AddModelError("Error", "Invalid Old Password");
                    return(View());
                }
            }

            else if (LoginType == "Customer")
            {
                var user = (from u in dbo.tblCustomers
                            where u.CustomerId.Equals(uid) && u.Pssd.Equals(Pssd)
                            select u).FirstOrDefault();

                try
                {
                    if (user.Pssd == Pssd)
                    {
                        if (Pssd == NewPssd)
                        {
                            ModelState.AddModelError("Error", "Old and New Password cannot be the same");
                            return(View());
                        }
                        user.Pssd    = NewPssd;
                        user.ConPssd = NewPssd;
                        dbo.SaveChanges();
                        return(RedirectToAction("Login", "Login"));
                    }
                }

                catch (Exception)
                {
                    ModelState.AddModelError("Error", "Invalid Old Password");
                    return(View());
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 20
0
        public ActionResult Login(Login credentials)
        {
            string Email     = credentials.Email;
            string Pssd      = credentials.Pssd;
            string LoginType = credentials.LoginType;

            dbCMSEntities dbo = new dbCMSEntities();

            try
            {
                if (LoginType == "SystemAdmin")
                {
                    var user = (from u in dbo.tblSystemAdmins
                                where u.Email.Equals(Email) && u.Pssd.Equals(Pssd)
                                select u).FirstOrDefault();


                    if (user.Pssd == Pssd)
                    {
                        Session["Id"]        = user.SystemAdminId;
                        Session["LoginType"] = LoginType;
                        return(RedirectToAction("Home", "SystemAdmin"));
                    }

                    ModelState.AddModelError("Error", "Invalid Email or Password");
                    return(View());
                }

                else if (LoginType == "ProductAdmin")
                {
                    var user = (from u in dbo.tblProductAdmins
                                where u.Email.Equals(Email) && u.Pssd.Equals(Pssd)
                                select u).FirstOrDefault();

                    if (user.Pssd == Pssd)
                    {
                        Session["Id"]        = user.ProductAdminId;
                        Session["LoginType"] = LoginType;
                        return(RedirectToAction("Home", "ProductAdmin"));
                    }

                    ModelState.AddModelError("Error", "Invalid Email or Password");
                    return(View());
                }

                else if (LoginType == "Worker")
                {
                    var user = (from u in dbo.tblWorkers
                                where u.Email.Equals(Email) && u.Pssd.Equals(Pssd)
                                select u).FirstOrDefault();

                    if (user.Pssd == Pssd)
                    {
                        Session["Id"]        = user.WorkerId;
                        Session["LoginType"] = LoginType;
                        return(RedirectToAction("Home", "Worker"));
                    }

                    ModelState.AddModelError("Error", "Invalid Email or Password");
                    return(View());
                }

                else if (LoginType == "Customer")
                {
                    var user = (from u in dbo.tblCustomers
                                where u.Email.Equals(Email) && u.Pssd.Equals(Pssd)
                                select u).FirstOrDefault();

                    if (user.Pssd == Pssd)
                    {
                        Session["Id"]        = user.CustomerId;
                        Session["LoginType"] = LoginType;
                        return(RedirectToAction("Home", "Customer"));
                    }

                    ModelState.AddModelError("Error", "Invalid Email or Password");
                    return(View());
                }
            }

            catch (System.NullReferenceException)
            {
                ModelState.AddModelError("Error", "Invalid Email or Password");
                return(View());
            }

            return(RedirectToAction("Index", "Home"));
        }