/// <summary>
        /// Converts to promo code list model.
        /// </summary>
        /// <param name="promoCodeModel">The model.</param>
        /// <returns></returns>
        public static List <PromoCodeDataListModel> BindPromoCodeListModel(List <PromoCode> promoCodeModel)
        {
            List <PromoCodeDataListModel> promoCodeListModel = new List <PromoCodeDataListModel>();

            if (promoCodeModel != null)
            {
                foreach (var item in promoCodeModel)
                {
                    PromoCodeDataListModel promoCodeDataListModel = new PromoCodeDataListModel();
                    if (item.Amount != null)
                    {
                        promoCodeDataListModel.Amount = DBHelper.ParseString(item.Amount);
                    }
                    promoCodeDataListModel.Code = item.Code;
                    if (item.StartDate.HasValue)
                    {
                        promoCodeDataListModel.StartDate = DBHelper.ParseString(Convert.ToDateTime(item.StartDate).ToString(Constants.PromocodeDateFormat));
                    }
                    if (item.StartDate.HasValue)
                    {
                        promoCodeDataListModel.ExpiryDate = DBHelper.ParseString(Convert.ToDateTime(item.ExpiryDate).ToString(Constants.PromocodeDateFormat));
                    }
                    promoCodeDataListModel.Name        = item.Name;
                    promoCodeDataListModel.Status      = item.Status;
                    promoCodeDataListModel.Description = item.Description;
                    promoCodeDataListModel.PromoCodeId = DBHelper.ParseString(item.PromoCodeId);
                    if (item.Percentage != null)
                    {
                        promoCodeDataListModel.Percentage = DBHelper.ParseString(item.Percentage);
                    }
                    promoCodeListModel.Add(promoCodeDataListModel);
                }
            }
            return(promoCodeListModel);
        }
Beispiel #2
0
 public IActionResult PromocodeDetail(GetPromoCodeDetailModel promoCodeDetailModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var promocodeDetail = iPromoCode.GetPromocodeDetail(DBHelper.ParseInt64(promoCodeDetailModel.promoCodeId));
             if (promocodeDetail != null)
             {
                 PromoCodeDataListModel promoCodeListModel = PromoCodeHelper.BindPromoCodeListModel(promocodeDetail);
                 return(Ok(ResponseHelper.Success(promoCodeListModel)));
             }
             else
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound)));
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }
        /// <summary>
        /// Converts to promo code list model.
        /// </summary>
        /// <param name="promoCodeModel">The model.</param>
        /// <returns></returns>
        public static PromoCodeDataListModel BindPromoCodeListModel(PromoCode promoCodeModel)
        {
            PromoCodeDataListModel promoCodeListModel = new PromoCodeDataListModel();

            if (promoCodeModel != null)
            {
                if (promoCodeModel.Amount != null)
                {
                    promoCodeListModel.Amount = DBHelper.ParseString(promoCodeModel.Amount);
                }
                promoCodeListModel.Code        = promoCodeModel.Code;
                promoCodeListModel.StartDate   = DBHelper.ParseString(Convert.ToDateTime(promoCodeModel.StartDate));
                promoCodeListModel.ExpiryDate  = DBHelper.ParseString(Convert.ToDateTime(promoCodeModel.ExpiryDate));;
                promoCodeListModel.Name        = promoCodeModel.Name;
                promoCodeListModel.Description = promoCodeModel.Description;
                promoCodeListModel.PromoCodeId = DBHelper.ParseString(promoCodeModel.PromoCodeId);
                if (promoCodeModel.Percentage != null)
                {
                    promoCodeListModel.Percentage = DBHelper.ParseString(promoCodeModel.Percentage);
                }
            }
            return(promoCodeListModel);
        }