示例#1
0
        public ActionResult Index(CustomPerkTask model)
        {
            string sMessage = "";

            if (ModelState.IsValid)
            {
                TittleUserServices service = new TittleUserServices();
                long   nID      = 0;
                string filename = "";
                if (model.image != null && model.image.ContentLength > 0)
                {
                    string websiteUrl = ConfigurationManager.AppSettings["WebsiteUrl"].ToString();
                    string filePath   = ConfigurationManager.AppSettings["TaskIconPath"].ToString();
                    filename = RandomString(15) + Path.GetExtension(model.image.FileName);
                    string fullPath = Server.MapPath(filePath + "/" + filename);
                    if (!Directory.Exists(Server.MapPath(filePath)))
                    {
                        Directory.CreateDirectory(Server.MapPath(filePath));
                    }
                    model.image.SaveAs(fullPath);
                    model.icon = websiteUrl + filePath + "/" + filename;
                }
                sMessage = service.SaveOrUpdatePerkTask(model, ref nID);
            }

            return(Json(new
            {
                message = sMessage
            }));
        }
示例#2
0
        public HttpResponseMessage TerminatedUsers(int type)
        {
            TittleUserServices us = new TittleUserServices();
            List <CustomChartData <string> > cd = us.DeactiveUsersCount(type);

            return(Request.CreateResponse(HttpStatusCode.OK, cd));
        }
        public DataTableResult <CustomUserPlan> SearchUserPlans(DataTableAjaxPostModel model)
        {
            var searchBy = (model.search != null) ? model.search.value : null;
            var take     = model.length;
            var skip     = model.start;

            string sortBy  = "";
            bool   sortDir = true;

            if (model.order != null)
            {
                // in this example we just default sort on the 1st column
                sortBy  = model.columns[model.order[0].column].data;
                sortDir = model.order[0].dir.ToLower() == "asc";
            }

            // search the dbase taking into consideration table sorting and paging
            TittleUserServices _Service             = new TittleUserServices();
            DataTableResult <CustomUserPlan> result = new Models.DataTableResult <CustomUserPlan>();
            int filteredResultsCount = 0;
            int totalResultsCount    = 0;

            result.result = _Service.GetUserPlans(searchBy, model.promoCode, model.plan, model.fromDate, model.toDate, take, skip, sortBy, sortDir, out filteredResultsCount, out totalResultsCount);
            result.filteredResultsCount = filteredResultsCount;
            result.totalResultsCount    = totalResultsCount;
            if (result.result == null)
            {
                // empty collection...
                return(new DataTableResult <CustomUserPlan>());
            }
            return(result);
        }
示例#4
0
        public HttpResponseMessage useractions()
        {
            TittleUserServices            us = new TittleUserServices();
            List <CustomChartData <int> > cd = us.UserActionsCount();

            return(Request.CreateResponse(HttpStatusCode.OK, cd));
        }
示例#5
0
        public ActionResult SendEmails(CustomNotify model)
        {
            if (Session["UserID"] != null)
            {
                TittleUserServices service = new TittleUserServices();
                List <string>      emails  = null;
                if (!string.IsNullOrEmpty(model.To))
                {
                    emails = model.To.Split('|').ToList();
                }
                else
                {
                    emails = service.GetAllUsersEmail();
                }

                //loop through users and send emails
                foreach (string email in emails)
                {
                    MailData mail = new MailData();
                    mail.Body    = model.Content;
                    mail.Subject = model.Subject;
                    mail.To      = email;
                    MailService.SendEmail(mail);
                }

                return(Json(new
                {
                    message = "success"
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new
            {
                message = "error"
            }, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        public HttpResponseMessage TotalUsers()
        {
            TittleUserServices       us = new TittleUserServices();
            CustomChartData <string> cd = us.TotalUsersCount();

            return(Request.CreateResponse(HttpStatusCode.OK, cd));
        }
示例#7
0
 public ActionResult UserInfo(int id)
 {
     if (Session["UserID"] != null)
     {
         TittleUserServices service = new TittleUserServices();
         CustomUserInfo     model   = service.GetUserInformations(id);
         return(PartialView("UserInfo", model));
     }
     return(null);
 }
示例#8
0
 // GET: User
 public ActionResult ResetPassword(int id)
 {
     if (Session["UserID"] != null)
     {
         TittleUserServices service = new TittleUserServices();
         CustomResetUser    model   = service.GetUserDetail(id);
         return(PartialView("ResetPassword", model));
     }
     return(null);
 }
示例#9
0
 public ActionResult ResetPassword(CustomPasswordReset reset)
 {
     if (ModelState.IsValid)
     {
         TittleUserServices _UserService = new TittleUserServices();
         if (_UserService.ResetPassword(reset.UserID, reset.Password, reset.Token))
         {
             ViewBag.ErrorMessage = "Password reset successfully.";
             return(RedirectToAction("Index", "Login"));
         }
     }
     ViewBag.ErrorMessage = "Please fill all the fields.";
     return(View("Index", reset));
 }
示例#10
0
        public ActionResult DeletePerkTask(int Id)
        {
            TittleUserServices service  = new TittleUserServices();
            string             sMessage = "";

            if (Id > 0)
            {
                service.DeletePerkTask(Id, ref sMessage);
            }
            return(Json(new
            {
                message = sMessage
            }));
        }
示例#11
0
        public ActionResult UserActive(CustomResetUser model)
        {
            if (Session["UserID"] != null)
            {
                TittleUserServices service = new TittleUserServices();
                service.ChangeUserActiveStatus(model);

                return(Json(new
                {
                    message = "success"
                }));
            }
            return(Json(new
            {
                message = "error"
            }));
        }
示例#12
0
        public ActionResult AddPerkTask(int Id)
        {
            TittleUserServices service = new TittleUserServices();

            CustomPerkTask model = new CustomPerkTask();

            if (Id > 0)
            {
                perks_tasks _data = service.GetPerkTaskInfo(Id);
                model.key              = _data.key;
                model.name             = _data.name;
                model.number_to_finish = _data.number_to_finish;
                model.score            = _data.score;
                model.icon             = _data.icon;
                model.id = _data.id;
            }
            return(PartialView("AddPerkTask", model));
        }
示例#13
0
        public JsonResult IsPerkTaskExist(string key, long id)
        {
            TittleUserServices service = new TittleUserServices();
            bool        isExist        = false;
            perks_tasks data           = service.GetPerkTaskByKey(key);

            if (data == null)
            {
                isExist = false;
            }
            else if (data.id == id)
            {
                isExist = false;
            }
            else
            {
                isExist = true;
            }

            return(Json(!isExist, JsonRequestBehavior.AllowGet));
        }
示例#14
0
        // GET: Reset
        public ActionResult Index()
        {
            string qstr = Convert.ToString(Request.QueryString["key"]);

            if (!string.IsNullOrEmpty(qstr))
            {
                TittleUserServices  _UserService = new TittleUserServices();
                string              sMessage     = "";
                CustomPasswordReset _user        = _UserService.ValidateResetKey(qstr, ref sMessage);
                if (sMessage != "")
                {
                    ViewBag.ErrorMessage = sMessage;
                    return(View());
                }
                else
                {
                    return(View(_user));
                }
            }
            ViewBag.ErrorMessage = "No token found.";
            return(View());
        }
示例#15
0
 public ActionResult UserLogin(CustomUserLogin _User)
 {
     if (ModelState.IsValid)
     {
         TittleUserServices _UserService = new TittleUserServices();
         string             strRet       = "";
         long nId = 0;
         _UserService.ValidateLoginInfo(_User.Email, _User.Password, ref nId, ref strRet);
         if (string.IsNullOrEmpty(strRet))
         {
             Session["UserID"] = nId;
             return(RedirectToAction("Index", "Dashboard"));
         }
         else
         {
             ViewBag.ErrorMessage = strRet;
             return(View("Index", _User));
         }
     }
     ViewBag.ErrorMessage = "Please enter Email/Password.";
     return(View("Index"));
 }
示例#16
0
 public ActionResult ForgetPassword(string Email)
 {
     if (!string.IsNullOrEmpty(Email.Trim()))
     {
         TittleUserServices _UserService = new TittleUserServices();
         string             strRet       = "";
         long nId = 0;
         _UserService.ValidateForgotEmail(Email, ref strRet);
         if (string.IsNullOrEmpty(strRet))
         {
             Session["UserID"] = nId;
             return(View("Index"));
         }
         else
         {
             ViewBag.ErrorMessage = strRet;
             return(View("Index"));
         }
     }
     ViewBag.ErrorMessage = "Please enter your email.";
     return(View("Index"));
 }
示例#17
0
        public DataTableResult <CustomUser> SearchRedeemUsers(DataTableAjaxPostModel model)
        {
            var searchBy = (model.search != null) ? model.search.value : null;
            var take     = model.length;
            var skip     = model.start;

            string sortBy  = "";
            bool   sortDir = true;

            if (model.order != null)
            {
                // in this example we just default sort on the 1st column
                sortBy  = model.columns[model.order[0].column].data;
                sortDir = model.order[0].dir.ToLower() == "asc";
            }

            // search the dbase taking into consideration table sorting and paging
            TittleUserServices           _UserServices = new TittleUserServices();
            DataTableResult <CustomUser> result        = new Models.DataTableResult <CustomUser>();
            int    filteredResultsCount = 0;
            int    totalResultsCount    = 0;
            int    iosCount             = 0;
            int    androidCount         = 0;
            string countryGrouping      = "";

            result.result = _UserServices.GetRedeemUsedUsersList(searchBy, take, skip, sortBy, sortDir, out filteredResultsCount, out totalResultsCount, out iosCount, out androidCount, out countryGrouping);
            result.filteredResultsCount = filteredResultsCount;
            result.totalResultsCount    = totalResultsCount;
            result.iosCount             = iosCount;
            result.androidCount         = androidCount;
            result.countryGrouping      = countryGrouping;
            if (result.result == null)
            {
                // empty collection...
                return(new DataTableResult <CustomUser>());
            }
            return(result);
        }
示例#18
0
        public ActionResult PushNotifications(CustomNotify model)
        {
            if (Session["UserID"] != null && ModelState.IsValid)
            {
                PushNotification           fcm      = new PushNotification();
                TittleUserServices         service  = new TittleUserServices();
                TittleNotificationServices nservice = new TittleNotificationServices();
                List <string> emails = null;

                if (model.Type == "immediately")
                {
                    if (!string.IsNullOrEmpty(model.To))
                    {
                        emails = model.To.Split('|').ToList();
                    }
                    else
                    {
                        emails = service.GetAllUsersEmail();
                    }
                    //loop through users and send notification
                    foreach (string email in emails)
                    {
                        List <CustomNotificationUser> users = nservice.GetUserDetailByEmail(email);
                        for (int j = 0; j < users.Count; j++)
                        {
                            //save in notification box
                            notification_boxes nb = new notification_boxes();
                            nb.type        = 10;
                            nb.device_id   = users[j].id;
                            nb.device_type = "App\\Models\\User";
                            nb.message     = model.Content;
                            nb.task_id     = 0;
                            nb.unread      = "";
                            nb.seen        = 0;
                            nb.kid_id_ref  = 0;
                            nservice.SaveNotificationBoxInfo(nb);
                            //send notification one by one to devices
                            List <device> devices = nservice.GetListOfDevices(users[j].id);
                            for (int k = 0; k < devices.Count; k++)
                            {
                                fcm.Send(10, model.Content, devices[k].id);
                            }
                        }
                    }
                }
                else
                {
                    CustomNotification not = new CustomNotification();
                    if (!string.IsNullOrEmpty(model.To))
                    {
                        not.data = "{\"users\":\"" + string.Join(",", model.To.Split('|')) + "\"}";
                    }
                    else
                    {
                        not.data = "{\"users\":\"all\"}";
                    }
                    not.content = model.Content;
                    not.name    = string.IsNullOrEmpty(model.Name)? "Unknown": model.Name;
                    not.OnDate  = model.TimeStart.HasValue ? model.TimeStart.Value.ToString("dd/MM/yyyy hh:mm tt") : null;
                    not.status  = model.Status;
                    not.type    = model.Type;
                    long nid = 0;
                    nservice.AddNotification(not, ref nid);
                }
                return(Json(new
                {
                    message = "success"
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new
            {
                message = "error"
            }, JsonRequestBehavior.AllowGet));
        }