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))); } }
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))); } }