Пример #1
0
 public IHttpActionResult PostBuyEnterpCard(EnterpCardsDTO enterpCardDTO)
 {
     if (EnterpCardsService.buyEnterpCard(enterpCardDTO) == null)
     {
         return(BadRequest("System error, please try later"));
     }
     return(Ok(enterpCardDTO));
 }
Пример #2
0
 public IHttpActionResult GetIsEnterpCardExist(EnterpCardsDTO enterpCardDTO)
 {
     //פונקתית סליקה
     if (EnterpCardsService.isEnterpCardExist(enterpCardDTO))
     {
         return(BadRequest("The card exists in the Enterprise"));
     }
     return(Ok("Card successfully registered"));
 }
Пример #3
0
 /// <summary>
 /// מקבלת כרטיס בעסק ובודקת האם קיים לעסק כזה כרטיס
 /// </summary>
 /// <param name="enterpCardDTO"></param>
 /// <returns></returns>
 public static bool isEnterpCardExist(EnterpCardsDTO enterpCardDTO)
 {
     using (ClubCardsEntities db = new ClubCardsEntities())
     {
         EnterpCards enterpCard = Conversion.EnterpCardsConversion.ConvertToEnterpCards(enterpCardDTO);
         if (db.EnterpCards.FirstOrDefault(x => x.EnterpId == enterpCard.EnterpId && x.Type == enterpCard.Type) != null)
         {
             return(true);
         }
         return(false);
     }
 }
Пример #4
0
        public static EnterpCards ConvertToEnterpCards(EnterpCardsDTO EnterpCardDTO)
        {
            EnterpCards newEnterpCard = new EnterpCards();

            newEnterpCard.C_id               = EnterpCardDTO.C_id;
            newEnterpCard.Cost               = EnterpCardDTO.Cost;
            newEnterpCard.EnterpId           = EnterpCardDTO.EnterpId;
            newEnterpCard.Type               = EnterpCardDTO.Type;
            newEnterpCard.Img                = EnterpCardDTO.Img;
            newEnterpCard.CountPoints        = EnterpCardDTO.CountPoints;
            newEnterpCard.PriseForBirthDayId = EnterpCardDTO.PriseForBirthDayId;
            newEnterpCard.PriseForNewId      = EnterpCardDTO.PriseForNewId;
            return(newEnterpCard);
        }
Пример #5
0
        public static EnterpCardsDTO ConvertToDTO(EnterpCards EnterpCard)
        {
            EnterpCardsDTO newEnterpCard = new EnterpCardsDTO();

            newEnterpCard.C_id               = EnterpCard.C_id;
            newEnterpCard.Cost               = EnterpCard.Cost;
            newEnterpCard.EnterpId           = EnterpCard.EnterpId;
            newEnterpCard.Type               = EnterpCard.Type;
            newEnterpCard.Img                = EnterpCard.Img;
            newEnterpCard.CountPoints        = EnterpCard.CountPoints;
            newEnterpCard.PriseForBirthDayId = EnterpCard.PriseForBirthDayId;
            newEnterpCard.PriseForNewId      = EnterpCard.PriseForNewId;
            return(newEnterpCard);
        }
Пример #6
0
 /// <summary>
 /// ומבצעת הוספה  של הכרטיס לטבלת כרטיסים לעסק EnterpCardsDTO  מקבלת משתנה מסוג
 /// </summary>
 /// <param name="enterpCardDTO"></param>
 /// <returns></returns>
 public static EnterpCardsDTO buyEnterpCard(EnterpCardsDTO enterpCardDTO)
 {
     using (ClubCardsEntities db = new ClubCardsEntities())
     {
         try
         {
             db.EnterpCards.Add(Conversion.EnterpCardsConversion.ConvertToEnterpCards(enterpCardDTO));
             db.SaveChanges();
             return(enterpCardDTO);
         }
         catch
         {
             return(null);
         }
     }
 }