/// <summary> /// Change Redeem Status /// </summary> /// <param name="nID"></param> /// <param name="sStatus"></param> /// <returns></returns> public string ChangeRedeemStatus(long nID, string sStatus) { string sMessage = "Success"; user_redeem obj = GetRedeemInfo(nID); using (var db = new TittleEntities()) { if (sStatus == "Approved") { obj.status = 1; } else if (sStatus == "Completed") { obj.status = 2; } else { obj.status = 0; } db.user_redeem.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } return(sMessage); }
/// <summary> /// Update translation info /// </summary> /// <param name="nID"></param> /// <param name="value"></param> /// <returns></returns> public string UpdateTranslation(long nID, string value) { string sMessage = "Success"; translation obj = new translation(); using (var db = new TittleEntities()) { obj = db.translations.Where(x => x.id == nID).FirstOrDefault(); if (obj != null && obj.id > 0) { obj.value = value; obj.updated_at = DateTime.Now; //update key db.translations.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); nID = obj.id; } else { sMessage = "Translation not exists."; } } return(sMessage); }
/// <summary> /// Update System Notification Info /// </summary> /// <returns></returns> public void UpdateSystemNotificationInfo(string value) { using (var db = new TittleEntities()) { system_settings obj = db.system_settings.Where(x => x.key == "reminder_notification").FirstOrDefault(); obj.value = value; db.system_settings.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } }
/// <summary> /// Save or update promo code info /// </summary> /// <param name="_promoCode"></param> /// <param name="nID"></param> /// <returns></returns> public string SaveOrUpdatePromoCode(CustomPromoCode _promoCode, ref long nID) { string sMessage = "Success"; promo_codes obj; if (_promoCode.id != 0) { obj = GetPromoCodeInfo(_promoCode.id); } else { obj = new promo_codes(); } using (var db = new TittleEntities()) { obj.code = _promoCode.CodeID; obj.description = _promoCode.Description; obj.end_date = DateTime.ParseExact(_promoCode.EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); obj.promo_type = _promoCode.TypeValue; obj.quantity = Convert.ToInt32(_promoCode.Quantity); obj.rule = string.IsNullOrEmpty(_promoCode.Rules) ? "" : _promoCode.Rules; obj.start_date = DateTime.ParseExact(_promoCode.StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); obj.type = _promoCode.type; obj.value = Convert.ToDecimal(_promoCode.Value); obj.updated_at = DateTime.Now; if (_promoCode.id != 0) { db.promo_codes.Attach(obj); db.Entry(obj).State = EntityState.Modified; } else { obj.created_at = DateTime.Now; db.promo_codes.Add(obj); } db.SaveChanges(); nID = obj.id; } return(sMessage); }
/// <summary> /// Save or update Notification info /// </summary> /// <param name="_notification"></param> /// <param name="nID"></param> /// <returns></returns> public string AddNotification(CustomNotification _notification, ref long nID) { string sMessage = "Success"; notification obj; if (_notification.id != 0) { obj = GetNotificationInfo(_notification.id); } else { obj = new notification(); } using (var db = new TittleEntities()) { obj.data = _notification.data; obj.content = _notification.content; obj.name = _notification.name; obj.time = DateTime.ParseExact(_notification.OnDate, "dd/MM/yyyy hh:mm tt", CultureInfo.InvariantCulture); obj.type = _notification.type; obj.next_notification = DateTime.ParseExact(_notification.NextNotificationDate, "dd/MM/yyyy hh:mm tt", CultureInfo.InvariantCulture); obj.status = _notification.status; obj.updated_at = DateTime.Now; if (_notification.id != 0) { db.notifications.Attach(obj); db.Entry(obj).State = EntityState.Modified; } else { obj.created_at = DateTime.Now; db.notifications.Add(obj); } db.SaveChanges(); nID = obj.id; } return(sMessage); }
/// <summary> /// Save or update Redemption Gift info /// </summary> /// <param name="_data"></param> /// <param name="nID"></param> /// <returns></returns> public string SaveOrUpdateRedemptionGift(CustomRedemptionGift _data, ref long nID) { string sMessage = "Success"; redeem obj; if (_data.id != 0) { obj = GetRedemptionGiftInfo(_data.id); } else { obj = new redeem(); } using (var db = new TittleEntities()) { obj.type = _data.type; obj.name = _data.name; obj.points = _data.points; obj.frequency = _data.frequency; obj.updated_at = DateTime.Now; if (_data.id != 0) { db.redeems.Attach(obj); db.Entry(obj).State = EntityState.Modified; } else { obj.created_at = DateTime.Now; db.redeems.Add(obj); } db.SaveChanges(); nID = obj.id; } return(sMessage); }