Ejemplo n.º 1
0
 public IActionResult UpdatePromoCode(AddPromoCodeModel addPromoCodeModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             PromoCode promoCodeModel = PromoCodeHelper.BindPromoCode(addPromoCodeModel);
             long      promoCodeId    = iPromoCode.UpdatePromocode(promoCodeModel);
             if (promoCodeId > 0)
             {
                 return(Ok(ResponseHelper.Success(MessageConstants.PromocodeUpdated)));
             }
             else if (promoCodeId == ReturnCode.AlreadyExist.GetHashCode())
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.TryDifferentCode)));
             }
             else
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.PromocodeNotUpdated)));
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Convers to promo code.
        /// </summary>
        /// <param name="addPromoCodeModel">The model.</param>
        /// <returns></returns>
        public static PromoCode BindPromoCode(AddPromoCodeModel addPromoCodeModel)
        {
            PromoCode promoCodeModel = new PromoCode();

            if (addPromoCodeModel != null)
            {
                if (!string.IsNullOrEmpty(addPromoCodeModel.PromoCodeId))
                {
                    promoCodeModel.PromoCodeId = DBHelper.ParseInt64(addPromoCodeModel.PromoCodeId);
                }
                promoCodeModel.Name = addPromoCodeModel.Name;
                promoCodeModel.Code = addPromoCodeModel.Code;
                if (!string.IsNullOrEmpty(addPromoCodeModel.StartDate))
                {
                    promoCodeModel.StartDate = Convert.ToDateTime(addPromoCodeModel.StartDate);
                }
                if (!string.IsNullOrEmpty(addPromoCodeModel.ExpiryDate))
                {
                    promoCodeModel.ExpiryDate = Convert.ToDateTime(addPromoCodeModel.ExpiryDate);
                }
                promoCodeModel.Description = addPromoCodeModel.Description;
                promoCodeModel.Amount      = DBHelper.ParseDecimal(addPromoCodeModel.Amount);
                promoCodeModel.Percentage  = DBHelper.ParseDecimal(addPromoCodeModel.Percentage);
                promoCodeModel.CreatedBy   = DBHelper.ParseInt64(addPromoCodeModel.CreatedBy);
                promoCodeModel.Status      = DBHelper.ParseInt32(addPromoCodeModel.Status);
                if (!string.IsNullOrEmpty(addPromoCodeModel.UpdatedBy))
                {
                    promoCodeModel.UpdatedBy = DBHelper.ParseInt64(addPromoCodeModel.UpdatedBy);
                }
            }
            return(promoCodeModel);
        }
Ejemplo n.º 3
0
 public IActionResult AddPromoCode(AddPromoCodeModel addPromoCodeModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             PromoCode promoCodeModel = PromoCodeHelper.BindPromoCode(addPromoCodeModel);
             if (!string.IsNullOrWhiteSpace(addPromoCodeModel.PromoCodeId) && DBHelper.ParseInt64(addPromoCodeModel.PromoCodeId) <= 0)
             {
                 promoCodeModel.CreatedOn = DateTime.Now;
                 long promoCodeId = iPromoCode.AddPromocode(promoCodeModel);
                 if (promoCodeId > 0)
                 {
                     return(Ok(ResponseHelper.Success(MessageConstants.PromocodeAdded)));
                 }
                 else if (promoCodeId == ReturnCode.AlreadyExist.GetHashCode())
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.TryDifferentCode)));
                 }
                 else
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.PromocodeNotAdded)));
                 }
             }
             else
             {
                 promoCodeModel.ModifiedOn = DateTime.Now;
                 long promoCodeId = iPromoCode.UpdatePromocode(promoCodeModel);
                 if (promoCodeId > 0)
                 {
                     return(Ok(ResponseHelper.Success(MessageConstants.PromocodeUpdated)));
                 }
                 else if (promoCodeId == ReturnCode.AlreadyExist.GetHashCode())
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.TryDifferentCode)));
                 }
                 else
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.PromocodeNotUpdated)));
                 }
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }