Esempio n. 1
0
        //Search is found- user bought the product
        public static WebResult <SearchDTO> Found(int codeSearch, string mailShop)
        {
            using (ProjectEntities db = new ProjectEntities())
            {
                Search search = db.Searches.Find(codeSearch);
                if (search == null)
                {
                    return new WebResult <SearchDTO>
                           {
                               Message = "לא נמצא חיפוש זה במאגר",
                               Status  = false,
                               Value   = null
                           }
                }
                ;
                search.status   = (int)EStatus.Found;
                search.codeShop = db.Shops.FirstOrDefault(f => f.mailShop == mailShop).codeShop;
                db.SaveChanges();

                return(new WebResult <SearchDTO>
                {
                    Message = "החיפוש נמצא בהצלחה",
                    Status = true,
                    Value = SearchCast.GetSearchDTO(search)
                });
            }
        }
Esempio n. 2
0
 //Delete search- status changes to 2
 public static WebResult <SearchDTO> Delete(int code)
 {
     using (ProjectEntities db = new ProjectEntities())
     {
         Search search = db.Searches.Find(code);
         if (search == null)
         {
             return new WebResult <SearchDTO>
                    {
                        Message = "לא נמצא חיפוש זה",
                        Status  = false,
                        Value   = null
                    }
         }
         ;
         search.status = (int)EStatus.Deleted;
         db.SaveChanges();
         return(new WebResult <SearchDTO>
         {
             Message = "המחיקה בוצעה בהצלחה",
             Status = true,
             Value = SearchCast.GetSearchDTO(search)
         });
     };
 }
Esempio n. 3
0
        //  הפונקציה מביאה לחנות את כל החיפושים שנמצאו אצלה
        public static WebResult <List <SearchDTO> > getSearchesForShop(int codeShop)
        {
            //בדיקת אבטחה...
            if (codeShop != (HttpContext.Current.Session["Shop"] as Shop).codeShop)
            {
                return new WebResult <List <SearchDTO> >
                       {
                           Message = "שגיאת אבטחה, חנות לא תואמת",
                           Value   = null,
                           Status  = false
                       }
            }
            ;
            List <SearchDTO> searchDTOs = new List <SearchDTO>();

            foreach (var item in db.Searches)
            {
                if (item.status == 1 && item.codeShop == (HttpContext.Current.Session["Shop"] as Shop).codeShop)
                {
                    searchDTOs.Add(SearchCast.GetSearchDTO(item));
                }
            }
            return(new WebResult <List <SearchDTO> >
            {
                Message = "רשימת החיפושים לחנות נשלחה בהצלחה",
                Status = true,
                Value = searchDTOs
            });
        }
Esempio n. 4
0
        //מחיקת חיפוש- המשתמש התחרט
        //החיפוש לא באמת מתבטל אלא הסטטוס משתנה ל2
        public static WebResult <SearchDTO> Delete(int code)
        {
            Search search = db.Searches.Find(code);

            if (search == null)
            {
                return new WebResult <SearchDTO>
                       {
                           Message = "לא נמצא חיפוש זה",
                           Status  = false,
                           Value   = null
                       }
            }
            ;
            if (search.status == 1)
            {
                return new WebResult <SearchDTO>
                       {
                           Message = "אין אפשרות למחו חיפושים שכבר נמצאו",
                           Status  = false,
                           Value   = null
                       }
            }
            ;
            search.status = 2;
            db.SaveChanges();
            return(new WebResult <SearchDTO>
            {
                Message = "המחיקה בוצעה בהצלחה",
                Status = true,
                Value = SearchCast.GetSearchDTO(search)
            });
        }
Esempio n. 5
0
 public static WebResult <List <SearchDTO> > UpdateAllSearchStatus()
 {
     using (ProjectEntities db = new ProjectEntities())
     {
         foreach (var s in db.Searches)
         {
             UpdateSearchStatus(s.codeSearch, CheckStatus(SearchCast.GetSearchDTO(s)), null);
         }
         db.SaveChanges();
         return(new WebResult <List <SearchDTO> >
         {
             Message = "רשימת מטלות עודכנה בהצלחה",
             Status = true,
             Value = SearchCast.GetSearchesDTO(db.Searches.ToList())
         });
     }
 }
Esempio n. 6
0
        //חיפוש נמצא- אם המשתמש קנה את המוצר
        public static WebResult <SearchDTO> Found(int codeSearch, int codeShop)
        {
            Search search = db.Searches.Find(codeSearch);

            if (search == null)
            {
                return new WebResult <SearchDTO>
                       {
                           Message = "לא נמצא חיפוש זה במאגר",
                           Status  = false,
                           Value   = null
                       }
            }
            ;
            search.status   = 1;
            search.codeShop = codeShop;
            db.SaveChanges();
            return(new WebResult <SearchDTO>
            {
                Message = "החיפוש נמצא בהצלחה",
                Status = true,
                Value = SearchCast.GetSearchDTO(search)
            });
        }