Example #1
0
        public ActionResult Create(CouponTypeModel coupon)
        {
            try
            {
                CouponType tempCoupon = coupon.ToCouponType();
                m_serviceLayer.AddCouponToDB(tempCoupon);

                log.InfoFormat("[CouponController.Create] coupon.Description={0}, coupon.", coupon.ToString());
                return RedirectToAction("Index");
            }
            catch(Exception e)
            {
                log.ErrorFormat("[CouponController.Create] Exception={0}.", e.ToString());
                return View();
            }
        }
Example #2
0
 public ActionResult Create()
 {
     log.InfoFormat("[CouponController.Create].");
     CouponTypeModel coupon = new CouponTypeModel();
     return View(coupon);
 }
Example #3
0
        public ActionResult Edit(CouponTypeModel couponModel)
        {
            try
            {
                log.InfoFormat("[CouponController.Edit] couponModel={0}", couponModel.ToString());
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    m_serviceLayer.UpdateCoupon(couponModel);
                    return RedirectToAction("Index");
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Example #4
0
        public static CouponTypeModel ToCouponTypeModel(this CouponType coupon)
        {
            try
            {
                log.InfoFormat("[ToCouponTypeModel] coupon.Id={0}, coupon.Description={1}.", coupon.Id.ToString(), coupon.Description);
                IServicesLayer m_serviceLayer = new ServiceLayerImpl();

                CouponTypeModel returnValue = new CouponTypeModel()
                {
                    Id = coupon.Id.ToString(),
                    Description = coupon.Description,
                    ValidFrom = coupon.ValidFrom,
                    ValidUntil = coupon.ValidUntil
                };

                if (coupon.RestaurantsIDs != null && coupon.RestaurantsIDs.Count > 0)
                {
                    returnValue.RestaurantID = coupon.RestaurantsIDs[0].ToString();
                    var tempRest = m_serviceLayer.GetRestaurantById(returnValue.RestaurantID);
                    if (tempRest != null) returnValue.LogoUrl = (tempRest.LocalUrl != null) ? tempRest.LocalUrl : tempRest.LogoUrl;
                    //returnValue.LogoUrl = "/Restaurant/GetImage/" + returnValue.RestaurantID;
                }
                if (coupon.LocationsList != null && coupon.LocationsList.Count > 0)
                {
                    returnValue.Location = new LocationModel(coupon.LocationsList[0]);
                }
                else
                {
                    returnValue.Location = new LocationModel(0, 0);
                    if (returnValue.Description.IndexOf("Nelly's Kitchen") > 0) returnValue.Location = new LocationModel(32.051, 34.755);
                    if (returnValue.Description.IndexOf("BG99") > 0) returnValue.Location = new LocationModel(32.016652, 34.738724);
                    if (returnValue.Description.IndexOf("קולומבוס") > 0) returnValue.Location = new LocationModel(32.161, 34.81);
                    if (returnValue.Description.IndexOf("Red Burger Bar") > 0) returnValue.Location = new LocationModel(32.33, 34.85);
                    if (returnValue.Description.IndexOf("Palamida") > 0) returnValue.Location = new LocationModel(32.084638, 34.803035);
                }

                return returnValue;
            }
            catch (Exception e)
            {
                log.ErrorFormat("[ToCouponTypeModel] Exception={0}.", e.ToString());
                return null;
            }
        }
Example #5
0
 public void UpdateCoupon(CouponTypeModel couponModel)
 {
     log.DebugFormat("[UpdateCoupon(couponModel)] couponModel={0}.", couponModel.ToString());
     CouponType coupon = couponModel.ToCouponType();
     UpdateCoupon(coupon);
 }
 public void UpdateCoupon(CouponTypeModel couponModel)
 {
     throw new NotImplementedException();
 }