protected override System.IAsyncResult BeginExecuteCore(System.AsyncCallback callback, object state)
        {
            System.Globalization.CultureInfo oCultureInfo =
                new System.Globalization.CultureInfo("fa-IR");

            System.Threading.Thread.CurrentThread.CurrentCulture   = oCultureInfo;
            System.Threading.Thread.CurrentThread.CurrentUICulture = oCultureInfo;

            User user = GetUserInfo.GetUser();

            if (user != null)
            {
                ViewBag.Name     = user.FullName;
                ViewBag.avatar   = user.AvatarImageUrl;
                ViewBag.Role     = user.Role.Title;
                ViewBag.RoleName = user.Role.Name;

                if (string.IsNullOrEmpty(user.AvatarImageUrl))
                {
                    ViewBag.avatar = "/assets/images/avatars/avatar_default.jpg";
                }
            }


            return(base.BeginExecuteCore(callback, state));
        }
        public ActionResult ChangePasswordConfirmed(ChangePasswordViewModel input)
        {
            if (ModelState.IsValid)
            {
                if (input.NewPassword != input.RepeatPassword)
                {
                    TempData["error"] = "تکرار کلمه عبور صحیح نمی باشد.";
                    return(View(input));
                }

                User user = GetUserInfo.GetUser();
                if (user.Password != input.OldPassword)
                {
                    TempData["error"] = "کلمه عبور پیشین صحیح نمی باشد.";
                    return(View(input));
                }

                user.Password         = input.NewPassword;
                user.LastModifiedDate = DateTime.Now;
                TempData["suucess"]   = "تغییرات با موفقیت انجام شد";

                db.SaveChanges();
            }
            return(View(input));
        }
예제 #3
0
        public ActionResult SupervisorIndex()
        {
            User user = GetUserInfo.GetUser();

            List <Project> projects = new List <Project>();

            if (user != null)
            {
                var projectDetails = db.ProjectDetails.Where(c => c.UserId == user.Id).Select(c => new
                {
                    c.ProjectId,
                    c.UserId
                });

                foreach (var projectDetail in projectDetails)
                {
                    if (projects.All(c => c.Id != projectDetail.ProjectId))
                    {
                        projects.Add(db.Projects.Find(projectDetail.ProjectId));
                    }
                }
            }

            return(View(projects));
        }
        public ActionResult EditByUser()
        {
            User user = GetUserInfo.GetUser();

            if (user == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CityId = new SelectList(db.Cities, "Id", "Title", user.CityId);
            return(View(user));
        }
예제 #5
0
        public ActionResult SupervisorIndex(Guid id)
        {
            User user = GetUserInfo.GetUser();

            var projectDetails = db.ProjectDetails.Include(p => p.Project)
                                 .Where(p => p.ProjectId == id && p.UserId == user.Id && p.IsDeleted == false)
                                 .Include(p => p.Store).OrderByDescending(p => p.CreationDate);

            var project = db.Projects.Where(c => c.Id == id).Select(c => c.Title);

            ViewBag.Title = "جزییات پروژه " + project.FirstOrDefault();
            return(View(projectDetails.ToList()));
        }
예제 #6
0
        public ActionResult PromoterIndex()
        {
            User user = GetUserInfo.GetUser();

            var dailyPromoterPlans = db.DailyPromoterPlans.Include(d => d.ProjectDetailPromoter)
                                     .Where(d => d.ProjectDetailPromoter.UserId == user.Id && d.IsDeleted == false)
                                     .OrderByDescending(d => d.ShiftDate);



            ViewBag.Title = "برنامه روزانه ";

            return(View(dailyPromoterPlans.ToList()));
        }
예제 #7
0
        public ActionResult PromoterDailyPlanAction(List <HttpPostedFileBase> attachments)
        {
            #region Upload and resize image if needed

            if (attachments != null)
            {
                foreach (HttpPostedFileBase t in attachments)
                {
                    if (t != null)
                    {
                        User user = GetUserInfo.GetUser();

                        DailyPromoterPlan dailyPromoterPlan = db.DailyPromoterPlans.FirstOrDefault(c =>
                                                                                                   c.ProjectDetailPromoter.UserId == user.Id && c.ShiftDate == DateTime.Today);

                        if (dailyPromoterPlan != null)
                        {
                            string filename    = Path.GetFileName(t.FileName);
                            string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                                 + Path.GetExtension(filename);

                            string newFilenameUrl   = "/Uploads/PromoterAttachment/" + newFilename;
                            string physicalFilename = Server.MapPath(newFilenameUrl);

                            t.SaveAs(physicalFilename);

                            DailyPromoterPlanAttachment dailyPromoterPlanAttachment = new DailyPromoterPlanAttachment()
                            {
                                Id                  = Guid.NewGuid(),
                                FileUrl             = newFilenameUrl,
                                CreationDate        = DateTime.Now,
                                DailyPromoterPlanId = dailyPromoterPlan.Id,
                                IsActive            = true,
                                IsDeleted           = false,
                            };
                            db.DailyPromoterPlanAttachments.Add(dailyPromoterPlanAttachment);
                        }
                    }
                }

                db.SaveChanges();
            }

            #endregion



            return(RedirectToAction("PromoterDailyPlanAction"));
        }
예제 #8
0
        public ActionResult PromoterDailyPlanActionById(Guid id)
        {
            PromoterDailyPlanActionViewModel result = new PromoterDailyPlanActionViewModel()
            {
                IsStart = false
            };
            User user = GetUserInfo.GetUser();

            DailyPromoterPlan dailyPromoterPlan = db.DailyPromoterPlans.Find(id);

            if (dailyPromoterPlan != null)
            {
                if (dailyPromoterPlan.ShiftDate == DateTime.Today)
                {
                    return(RedirectToAction("PromoterDailyPlanAction"));
                }

                ViewBag.dailyPromoterPlanId = dailyPromoterPlan.Id;

                if (dailyPromoterPlan.StartHour != null)
                {
                    result.IsStart = true;
                }

                if (dailyPromoterPlan.FinishHour != null)
                {
                    result.IsFinish = true;
                }

                result.StartTime  = dailyPromoterPlan.StartHourStr;
                result.FinishTime = dailyPromoterPlan.FinishHourStr;
                result.ShiftDate  = dailyPromoterPlan.ShiftDateStr;

                Project project = dailyPromoterPlan.ProjectDetailPromoter.ProjectDetail.Project;
                result.ProjectTitle    = project.Title;
                result.BrandTitle      = project.Customer.Title;
                result.Description     = project.Body;
                result.StoreTitle      = dailyPromoterPlan.ProjectDetailPromoter.ProjectDetail.Store.Title;
                result.ProjectProducts = GetProjectProduct(project.Id, dailyPromoterPlan.Id);
                result.DailyPromoterPlanAttachments = db.DailyPromoterPlanAttachments.Where(c =>
                                                                                            c.DailyPromoterPlanId == dailyPromoterPlan.Id && c.IsDeleted == false && c.IsActive == true)
                                                      .ToList();

                result.SupervisorFullname = dailyPromoterPlan.ProjectDetailPromoter.User.FullName;
                result.ProjectAttachments = GetProjectAttachment(project.Id);
            }

            return(View(result));
        }
        public ActionResult ChangePassword()
        {
            User user = GetUserInfo.GetUser();

            if (user == null)
            {
                return(HttpNotFound());
            }
            ChangePasswordViewModel result = new ChangePasswordViewModel()
            {
                Id = user.Id
            };

            return(View(result));
        }