コード例 #1
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
        //עדכון מספר צפיות למודעה
        public static void UpdateAdViews(AdvertisementsDTO a)
        {
            Advertisement ad = db.Advertisements.FirstOrDefault(x => x.AdId == a.AdId);

            ad.AdViews = ad.AdViews + 1;
            db.SaveChanges();
        }
コード例 #2
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
        //עידכון מודעה
        public static void UpdateAd(AdvertisementsDTO a)
        {
            Advertisement ad = db.Advertisements.FirstOrDefault(x => x.AdId == a.AdId);

            ad.AdHeight    = a.AdHeight;
            ad.AdWidth     = a.AdWidth;
            ad.AdDateBegin = a.AdDateBegin;
            ad.AdDateEnd   = a.AdDateEnd;
            ad.AdCategory  = a.AdCategory;
            db.SaveChanges();
        }
コード例 #3
0
 //place advertisment
 public void AddAdvertismentToMat(AdvertisementsDTO ad, int begin)
 {
     for (int a = begin / 10; a < begin / 10 + ad.AdHeight; a++)
     {
         for (int b = begin % 10; b < begin % 10 + ad.AdWidth; b++)
         {
             mat[a, b] = ad.AdId;
         }
     }
     PanelToDal(ad.AdId, begin, (int)ad.AdHeight, (int)ad.AdWidth);
 }
コード例 #4
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
 // מחזיר את  רשימת המודעות הממתינות לאישור
 public static List <AdvertisementsDTO> GetAllFalseAdvertisments()
 {
     try
     {
         return(AdvertisementsDTO.ListToDTO(db.Advertisements.Where(x => x.AdStatus == false).ToList()));
     }
     catch (Exception e)
     {
         throw new Exception();
     }
 }
コード例 #5
0
 public IHttpActionResult UpdateAd([FromBody] AdvertisementsDTO a)
 {
     try
     {
         Bll.AdvertismentsBLL.UpdateAd(a);
         return(Ok(a));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
コード例 #6
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
        //כל המודעות לפי חודשים
        //public static List<AdvertisementsDTO> GetAdvertisementsByDate(DateTime date)
        //{
        //    return AdvertisementsDTO.ListToDTO(db.Advertisements.Where(a => a.AdDateBegin.Month >= date.Month && a.AdDateEnd.Month <= date.Month &&
        //     a.AdDateBegin.y >= date.Year && a.AdDateEnd.Year <= date.Year && a.AdStatus == true).ToList());

        //הוספת מודעה
        public static bool AddAdvertisement(AdvertisementsDTO ad)
        {
            Advertisement advertisement = db.Advertisements.FirstOrDefault(x => x.AdFiles == ad.AdFiles);

            if (advertisement == null)
            {
                Advertisement a = AdvertisementsDTO.ToDAL(ad);
                db.Advertisements.Add(a);
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
コード例 #7
0
 //בודק האם המודעה כבר קיימת בלוח -מונע כפלויות
 public string ChecksDuplicates(AdvertisementsDTO a, DateTime date, int boardid)
 {
     //int boardid = db.Billboards.FirstOrDefault(x => x.BoardCity == city && x.BoardStreet == street).BoardId;
     mat = BuildMat(date, boardid);
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             if (mat[i, j] == a.AdId)
             {
                 return("yes");
             }
         }
     }
     return("no");
 }
コード例 #8
0
 //כאשר  הלקוח בוחר טווח תאריכים, בודק האם יש מקום למודעה, בלי להתחשב במיקום המדויק
 public bool CheckPlace(AdvertisementsDTO a, DateTime date, int boardid)
 {
     for (int i = 0; i < x; i++)
     {
         for (int j = 0; j < y; j++)
         {
             if (mat[i, j] == 0)
             {
                 if (CountPlace((int)a.AdWidth, (int)a.AdHeight, i, j))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
コード例 #9
0
 public IHttpActionResult AddAdvertisment([FromBody] AdvertisementsDTO a)
 {
     try
     {
         if (Bll.AdvertismentsBLL.AddAdvertisement(a))
         {
             return(Ok());  // להוסיף תאריך וקוד לוח
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception e)
     {
         return(BadRequest());
     }
 }
コード例 #10
0
 public IHttpActionResult ChangeStatus([FromBody] AdvertisementsDTO a)
 {
     try
     {
         if (Bll.AdvertismentsBLL.ChangeStatus(a))
         {
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception e)
     {
         return(BadRequest());
     }
 }
コード例 #11
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
        //משנה סטטוס של מודעה שאושרה
        public static bool ChangeStatus(AdvertisementsDTO a)
        {
            try
            {
                Advertisement newad = db.Advertisements.FirstOrDefault(x => x.AdId == a.AdId);


                if (newad != null)
                {
                    newad.AdStatus = true;
                    db.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #12
0
        //בודק האם יש מקום למודעה בתאריכים הרצויים
        public List <DateTime> Approval(AdvertisementsDTO a, string city, string street, bool IsToCheck)
        {
            string          Duplicates;
            int             boardid;
            Billboard       bill      = db.Billboards.FirstOrDefault(x => x.BoardCity == city && x.BoardStreet == street);
            List <DateTime> listDates = new List <DateTime>();

            if (bill != null)
            {
                boardid = bill.BoardId;
                bool     begin = false;
                DateTime date  = (DateTime)a.AdDateBegin;
                while (date < a.AdDateEnd)
                {
                    if (IsToCheck == true)
                    {
                        Duplicates = ChecksDuplicates(a, date, boardid);
                        if (Duplicates == "yes")
                        {
                            return(null);
                        }
                        begin = ArrangePlace(a, date, boardid, IsToCheck);
                        //אולי האופציה הזאת יותר טובה אבל קודם צריך לשלוח לBUILDMA
                        //begin=CheckPlace(a, date, boardid);
                    }

                    else
                    {
                        begin = ArrangePlace(a, date, boardid, IsToCheck);
                    }
                    if (begin == true)
                    {
                        listDates.Add(date);
                    }
                    date = date.AddDays(7);
                }
            }
            return(listDates);
        }
コード例 #13
0
        //the first method to organize the matrix
        public bool ArrangePlace(AdvertisementsDTO a, DateTime date, int boardid, bool istocheck)
        {
            this.date    = date;
            this.boardId = boardid;
            int max = 0, cnt, begin = 0, flag = 0;

            mat = BuildMat(date, boardid);
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    if (mat[i, j] == 0)
                    {
                        if (CountPlace((int)a.AdWidth, (int)a.AdHeight, i, j))
                        {
                            flag = 1;
                            cnt  = neighbors((int)a.AdWidth, (int)a.AdHeight, i, j);
                            if (cnt > max)
                            {
                                max   = cnt;
                                begin = i * 10 + j;
                            }
                        }
                    }
                }
            }
            if (flag == 1 && !istocheck)
            {
                AddAdvertismentToMat(a, begin);
            }
            if (flag == 1)
            {
                return(true);
            }
            return(false);
        }
コード例 #14
0
        public bool AddNewAdvertisment(AdvertisementsDTO a, DateTime date, int boardid, bool istocheck)
        {
            Add_Advertisment_BLL ab = new Add_Advertisment_BLL();

            return(ab.ArrangePlace(a, date, boardid, istocheck));
        }
コード例 #15
0
 public string ChecksDuplicates([FromUri] AdvertisementsDTO a, [FromUri] DateTime date, [FromUri] int boardid)
 {
     return(adbll.ChecksDuplicates(a, date, boardid));
 }
コード例 #16
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
 //כל המודעות
 public static List <AdvertisementsDTO> GetAllAdvertisements()
 {
     return(AdvertisementsDTO.ListToDTO(db.Advertisements.Where(a => a.AdStatus == true && a.AdDateBegin != null).ToList()));
 }
コード例 #17
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
 //כל המודעות לפי קוד משתמש
 public static List <AdvertisementsDTO> GetAllAdvertisementsForUser(int userid)
 {
     return(AdvertisementsDTO.ListToDTO(db.Advertisements.Where(a => a.AdUserId == userid && a.AdStatus == true).ToList()));
 }
コード例 #18
0
ファイル: AdvertismentsBLL.cs プロジェクト: giliShtarck/bill
 //חיפוש מודעה לפי קטגוריה
 public static List <AdvertisementsDTO> GetAdvertismentByCategory(string category)
 {
     return(AdvertisementsDTO.ListToDTO(db.Advertisements.Where(x => x.Category.CategoryName == category && x.AdStatus == true &&
                                                                x.AdDateBegin != null).ToList()));
 }