예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <summary>
        /// Save or update Language info
        /// </summary>
        /// <param name="newLang"></param>
        /// <param name="nID"></param>
        /// <returns></returns>
        public string SaveOrUpdateLanguage(CustomNewLanguage newLang, ref long nID)
        {
            string sMessage = "Success";

            language obj = new language();


            using (var db = new TittleEntities())
            {
                obj.locale     = newLang.locale;
                obj.label      = newLang.langLabel;
                obj.created_at = DateTime.Now;
                obj.updated_at = DateTime.Now;
                db.languages.Add(obj);
                db.SaveChanges();

                //add entry in translation
                StringBuilder strQuery = new StringBuilder();
                strQuery.Append("INSERT INTO `translations` ");
                strQuery.Append("(`language_id`,`key_id`,`value`,`created_at`,`updated_at`) ");
                strQuery.Append("select " + obj.id.ToString() + ",id,'',NOW(),NOW() from `keys`");
                var _dataQuery = db.Database.ExecuteSqlCommand(strQuery.ToString());
                nID = obj.id;
            }

            return(sMessage);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <summary>
        /// Delete key info
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public string Deletekey(long nID)
        {
            string sMessage = "Success";

            key obj = new key();


            using (var db = new TittleEntities())
            {
                obj = db.keys.Where(x => x.id == nID).FirstOrDefault();
                if (obj != null && obj.id > 0)
                {
                    //delete translation data
                    StringBuilder strQuery = new StringBuilder();
                    strQuery.Append("Delete from `translations` ");
                    strQuery.Append("WHERE key_id=" + nID.ToString() + " AND id!=0");
                    var _dataQuery = db.Database.SqlQuery <CustomLanguage>(strQuery.ToString()).ToList();

                    //delete key
                    db.keys.Attach(obj);
                    db.keys.Remove(obj);
                    db.SaveChanges();

                    nID = obj.id;
                }
                else
                {
                    sMessage = "Key not exists.";
                }
            }

            return(sMessage);
        }
예제 #5
0
        /// <summary>
        /// Save or update Key info
        /// </summary>
        /// <param name="newKey"></param>
        /// <param name="nID"></param>
        /// <returns></returns>
        public string SaveOrUpdateKey(key newKey, ref long nID)
        {
            string sMessage = "Success";

            key obj = new key();


            using (var db = new TittleEntities())
            {
                obj = db.keys.Where(x => x.key1 == newKey.key1).FirstOrDefault();
                if (obj == null || obj.id == 0)
                {
                    newKey.created_at = DateTime.Now;
                    newKey.updated_at = DateTime.Now;
                    db.keys.Add(newKey);
                    db.SaveChanges();

                    //add entry in translation
                    StringBuilder strQuery = new StringBuilder();
                    strQuery.Append("INSERT INTO `translations` ");
                    strQuery.Append("(`language_id`,`key_id`,`value`,`created_at`,`updated_at`) ");
                    strQuery.Append("select id," + newKey.id.ToString() + ",'',NOW(),NOW() from languages");
                    var _dataQuery = db.Database.ExecuteSqlCommand(strQuery.ToString());
                    nID = newKey.id;
                }
                else
                {
                    sMessage = "Key already exist.";
                }
            }

            return(sMessage);
        }
예제 #6
0
        /// <summary>
        /// Delete Language info
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public string DeleteLanguage(long nID)
        {
            string sMessage = "Success";

            language obj = new language();


            using (var db = new TittleEntities())
            {
                obj = db.languages.Where(x => x.id == nID).FirstOrDefault();
                if (obj != null && obj.id > 0)
                {
                    //delete translation data
                    StringBuilder strQuery = new StringBuilder();
                    strQuery.Append("Delete from `translations` ");
                    strQuery.Append("WHERE language_id=" + nID.ToString() + " AND id!=0");
                    var _dataQuery = db.Database.ExecuteSqlCommand(strQuery.ToString());

                    //delete language
                    db.languages.Attach(obj);
                    db.languages.Remove(obj);
                    db.SaveChanges();

                    nID = obj.id;
                }
                else
                {
                    sMessage = "Language not exists.";
                }
            }

            return(sMessage);
        }
예제 #7
0
 /// <summary>
 /// Update notification info
 /// </summary>
 /// <returns></returns>
 public void UpdateNotificationInfo(notification obj)
 {
     using (var db = new TittleEntities())
     {
         db.notifications.Add(obj);
         db.SaveChanges();
     }
 }
예제 #8
0
 /// <summary>
 /// Save notification box info
 /// </summary>
 /// <returns></returns>
 public void SaveNotificationBoxInfo(notification_boxes obj)
 {
     using (var db = new TittleEntities())
     {
         db.notification_boxes.Add(obj);
         db.SaveChanges();
     }
 }
예제 #9
0
        /// <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();
            }
        }
예제 #10
0
        /// <summary>
        /// Delete Promo Code
        /// </summary>
        /// <returns></returns>
        public void DeletePromoCode(long nID, ref string sMessage)
        {
            sMessage = "Delete can't be completed , there are ";
            promo_codes obj = GetPromoCodeInfo(nID);

            using (var db = new TittleEntities())
            {
                db.promo_codes.Attach(obj);
                db.promo_codes.Remove(obj);
                db.SaveChanges();
            }
            sMessage = "Success";
        }
예제 #11
0
        /// <summary>
        /// Delete Notification
        /// </summary>
        /// <returns></returns>
        public void DeleteNotification(long nID, ref string sMessage)
        {
            sMessage = "Delete can't be completed , there are ";
            notification obj = GetNotificationInfo(nID);

            using (var db = new TittleEntities())
            {
                db.notifications.Attach(obj);
                db.notifications.Remove(obj);
                db.SaveChanges();
            }
            sMessage = "Success";
        }
예제 #12
0
        /// <summary>
        /// Delete Redemption Gift
        /// </summary>
        /// <returns></returns>
        public void DeleteRedemptionGift(long nID, ref string sMessage)
        {
            sMessage = "Delete can't be completed , there are ";
            redeem obj = GetRedemptionGiftInfo(nID);

            using (var db = new TittleEntities())
            {
                db.redeems.Attach(obj);
                db.redeems.Remove(obj);
                db.SaveChanges();
            }
            sMessage = "Success";
        }
예제 #13
0
        /// <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);
        }
예제 #14
0
        /// <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);
        }
예제 #15
0
        /// <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);
        }