Beispiel #1
0
        public ActionResult Order()
        {
            EntitieFinal entitieFinal = new EntitieFinal();
            string       demand       = Request["dem"];

            ViewData["demand"] = demand;
            if (Request.Cookies["loginState"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            var userName = Request.Cookies["loginState"].Value;

            if (userName == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            var user = entitieFinal.CUSTOMERs.Single(p => p.CUSTOMER_NAME == userName);

            try
            {
                ALL_PHOTO aLL_PHOTO = new ALL_PHOTO();
                aLL_PHOTO.PHOTO_ADDRESS     = (string)TempData["PhotoID"];
                aLL_PHOTO.PHOTO_REQUIREMENT = demand;
                aLL_PHOTO.PHOTO_SIZE        = 42;
                aLL_PHOTO.PHOTO_STATUS      = 0;
                entitieFinal.ALL_PHOTO.Add(aLL_PHOTO);
                entitieFinal.SaveChanges();
                CONTRACT_PHOTO_INFO contract = new CONTRACT_PHOTO_INFO();
                contract.CONTRACT_USER_ID          = user.CUSTOMER_ID;
                contract.CONTRACT_PHOTO_ID         = entitieFinal.ALL_PHOTO.Single(p => p.PHOTO_ADDRESS == aLL_PHOTO.PHOTO_ADDRESS).PHOTO_ID;
                contract.CONTRACT_PHOTOREPAIRER_ID = 1;
                contract.CONTRACT_START_DATE       = new DateTime();
                contract.CONTRACT_END_DATE         = new DateTime();
                contract.CONTRACT_PAYMENT          = 80;
                contract.CONTRACT_STATUS           = 0;
                entitieFinal.CONTRACT_PHOTO_INFO.Add(contract);
                entitieFinal.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(View());
        }
        public ActionResult PicAddOrSearch(string op)
        {
            ViewData["front"] = "2";
            EntitieFinal entitie = new EntitieFinal();

            if (op == "add")
            {
                var pic = new CONTRACT_PHOTO_INFO();
                pic.CONTRACT_PHOTO_ID         = long.Parse(Request["PICID"]);
                pic.CONTRACT_USER_ID          = long.Parse(Request["USER"]);
                pic.CONTRACT_PHOTOREPAIRER_ID = long.Parse(Request["REP"]);
                pic.CONTRACT_START_DATE       = Convert.ToDateTime(Request["START"]);
                pic.CONTRACT_END_DATE         = Convert.ToDateTime(Request["END"]);
                pic.CONTRACT_PAYMENT          = long.Parse(Request["PAY"]);
                pic.CONTRACT_STATUS           = 0;
                entitie.CONTRACT_PHOTO_INFO.Add(pic);
                entitie.SaveChanges();
                GetData();
                return(RedirectToAction("AdminView"));
            }
            else
            {
                var picList = from pic in entitie.CONTRACT_PHOTO_INFO
                              select pic;
                if (!string.IsNullOrEmpty(Request["PICID"]))
                {
                    var p = long.Parse(Request["PICID"]);
                    picList = from pic in picList
                              where pic.CONTRACT_PHOTO_ID == p
                              select pic;
                }
                if (!string.IsNullOrEmpty(Request["USER"]))
                {
                    var p = long.Parse(Request["USER"]);
                    picList = from pic in picList
                              where pic.CONTRACT_USER_ID == p
                              select pic;
                }
                if (!string.IsNullOrEmpty(Request["REP"]))
                {
                    var p = long.Parse(Request["REP"]);
                    picList = from pic in picList
                              where pic.CONTRACT_PHOTOREPAIRER_ID == p
                              select pic;
                }
                if (!string.IsNullOrEmpty(Request["START"]))
                {
                    var p = Convert.ToDateTime(Request["START"]);
                    picList = from pic in picList
                              where pic.CONTRACT_START_DATE == p
                              select pic;
                }
                if (!string.IsNullOrEmpty(Request["END"]))
                {
                    var p = Convert.ToDateTime(Request["END"]);
                    picList = from pic in picList
                              where pic.CONTRACT_END_DATE == p
                              select pic;
                }
                if (!string.IsNullOrEmpty(Request["PAY"]))
                {
                    var p = Convert.ToDecimal(Request["PAY"]);
                    picList = from order in picList
                              where order.CONTRACT_PAYMENT == p
                              select order;
                }
                GetData();
                ViewData["PIC"] = picList.ToList();
            }


            return(View("AdminView"));
        }