Ejemplo n.º 1
0
        public IActionResult CommitView(Models.AdminForwardedRequests obj)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));

            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            int cidn = Convert.ToInt32(HttpContext.Session.GetString("uid"));

            Models.FarmerStock obj1 = new Models.FarmerStock();
            obj1.Item        = obj.Item;
            obj1.Quantity    = obj.Quantity;
            obj1.Uid         = cidn;
            TempData["Arid"] = obj.Arid;
            return(View(obj1));
        }
Ejemplo n.º 2
0
        public IActionResult FarmDetails(Models.FarmerStock farmer)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));

            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            Users obj = repObj.GetUserDetails(farmer.Uid);

            Models.FarmerUser up = _mapper.Map <Models.FarmerUser>(obj);

            return(View(up));
        }
Ejemplo n.º 3
0
        public IActionResult SaveUpdatedProduct(Models.FarmerStock product)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));


            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            if (product.PricePerUnit < 1)
            {
                TempData["-veprice"] = "Invalid Price! Updation failed.";
                return(RedirectToAction("ViewStock", "Farmer"));
            }
            bool status = false;

            if (ModelState.IsValid)
            {
                try
                {
                    int cidn = Convert.ToInt32(HttpContext.Session.GetString("uid"));
                    status = repObj.UpdateProduct(_mapper.Map <Infosys.BioKartDAL.Models.FarmerStock>(product), cidn);
                    if (status)
                    {
                        return(RedirectToAction("ViewStock"));
                    }
                    else
                    {
                        return(View("Error"));
                    }
                }
                catch (Exception)
                {
                    return(View("Error"));
                }
            }
            return(View("UpdateProduct", product));
        }
Ejemplo n.º 4
0
        public IActionResult Deletestock(Models.FarmerStock userObj)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));

            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            return(View(userObj));
        }
Ejemplo n.º 5
0
        public IActionResult SaveDeletionStock(Models.FarmerStock Obj)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));


            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            bool status = false;

            try
            {
                int cidn = Convert.ToInt32(HttpContext.Session.GetString("uid"));
                status = repObj.DeleteStock(cidn, Obj.Item);
                if (status)
                {
                    return(RedirectToAction("ViewStock"));
                }
                else
                {
                    return(View("Error"));
                }
            }
            catch (Exception)
            {
                return(View("Error"));
            }
        }
Ejemplo n.º 6
0
        public IActionResult Commit(Models.FarmerStock obj)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));


            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            bool status = false;

            try
            {
                int cidn = Convert.ToInt32(HttpContext.Session.GetString("uid"));
                if (obj.PricePerUnit < 1)
                {
                    TempData["InvalidRashi"] = "Invalid Price, Set unit price atleast ₹ 1.00";
                    return(RedirectToAction("CustomerRequests", "Farmer"));
                }

                status = repObj.AddProduct(_mapper.Map <Infosys.BioKartDAL.Models.FarmerStock>(obj), cidn);
                int?arid = TempData["Arid"] as int?;
                if (status)
                {
                    bool ij = repObj.CloseRequest(arid, cidn);

                    if (ij)
                    {
                        int  cid = repObj.GetCustomerID(arid);
                        int? rid = repObj.GetCustomerRID(arid);
                        bool s   = repObj.PushSuccessNotification(rid, cid, cidn);
                        if (s)
                        {
                            return(RedirectToAction("ViewStock", "Farmer"));
                        }
                        else
                        {
                            return(View("Error"));
                        }
                    }
                    return(View("Error"));
                }
                else
                {
                    return(View("Error"));
                }
            }
            catch (Exception)
            {
                return(View("Error"));
            }
        }
Ejemplo n.º 7
0
        public IActionResult SaveAddedProduct(Models.FarmerStock product)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));


            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            bool containsInt = product.Item.Any(char.IsDigit);

            if (product.CategoryId == null)
            {
                TempData["AddProductFarmer"] = "Please Select a Category!";
                return(RedirectToAction("AddProduct", "farmer"));
            }

            if (containsInt)
            {
                TempData["AddProductFarmer"] = "Invalid Item Name!";
                return(RedirectToAction("AddProduct", "farmer"));
            }
            bool status = false;

            if (product.PricePerUnit < 1)
            {
                TempData["AddProductFarmer"] = "Invalid Price!";
                return(RedirectToAction("AddProduct", "farmer"));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    int cidn = Convert.ToInt32(HttpContext.Session.GetString("uid"));

                    status = repObj.AddProduct(_mapper.Map <Infosys.BioKartDAL.Models.FarmerStock>(product), cidn);
                    if (status)
                    {
                        return(RedirectToAction("ViewStock"));
                    }
                    else
                    {
                        return(View("Error"));
                    }
                }
                catch (Exception)
                {
                    return(View("Error"));
                }
            }
            return(View("AddProduct", product));
        }