示例#1
0
        public ActionResult SubmitLocation(string latitude, string longitude, string requestType, string id)
        {
            try
            {
                Guid dailyPromoterPlanId = new Guid(id);

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

                if (requestType == "start")
                {
                    dailyPromoterPlan.StartLat  = latitude;
                    dailyPromoterPlan.StartLong = longitude;
                    dailyPromoterPlan.StartHour = DateTime.Now.Hour;
                    dailyPromoterPlan.StartMin  = DateTime.Now.Minute;
                }
                else
                {
                    dailyPromoterPlan.FinishLat  = latitude;
                    dailyPromoterPlan.FinishLong = longitude;
                    dailyPromoterPlan.FinishHour = DateTime.Now.Hour;
                    dailyPromoterPlan.FinishMin  = DateTime.Now.Minute;
                }

                db.SaveChanges();

                return(Json("true", JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            DailyPromoterPlan dailyPromoterPlan = db.DailyPromoterPlans.Find(id);

            dailyPromoterPlan.IsDeleted    = true;
            dailyPromoterPlan.DeletionDate = DateTime.Now;

            db.SaveChanges();
            return(RedirectToAction("Index", new { id = dailyPromoterPlan.ProjectDetailPromoterId }));
        }
示例#3
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"));
        }
示例#4
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));
        }
示例#5
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DailyPromoterPlan dailyPromoterPlan = db.DailyPromoterPlans.Find(id);

            if (dailyPromoterPlan == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProjectDetailPromoterId = dailyPromoterPlan.ProjectDetailPromoterId;
            return(View(dailyPromoterPlan));
        }
示例#6
0
        public ActionResult Create(DailyPromoterPlan dailyPromoterPlan, Guid id)
        {
            if (ModelState.IsValid)
            {
                dailyPromoterPlan.IsActive = true;
                dailyPromoterPlan.ProjectDetailPromoterId = id;
                dailyPromoterPlan.IsDeleted    = false;
                dailyPromoterPlan.CreationDate = DateTime.Now;
                dailyPromoterPlan.Id           = Guid.NewGuid();
                db.DailyPromoterPlans.Add(dailyPromoterPlan);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = id }));
            }

            ViewBag.ProjectDetailPromoterId = id;
            return(View(dailyPromoterPlan));
        }
        public ActionResult CreatePromoter(ProjectDetailPromoterViewModel input)
        {
            if (db.ProjectDetailPromoters.Any(c =>
                                              c.UserId == input.UserId && c.ProjectDetailId == input.ProjectDetailId && c.IsDeleted == false))
            {
                TempData["invalidPromoter"] = "پروموتر انتخابی قبلا برای این پروژه انتخاب شده است. پروموتر دیگری را انتخاب کنید.";
                return(RedirectToAction("index", new { id = input.ProjectDetailId }));
            }

            ProjectDetailPromoter projectDetailPromoter = new ProjectDetailPromoter()
            {
                Id              = Guid.NewGuid(),
                IsActive        = true,
                IsDeleted       = false,
                IsFullTime      = true,
                ProjectDetailId = input.ProjectDetailId,
                UserId          = input.UserId.Value,
                CreationDate    = DateTime.Now,
            };

            db.ProjectDetailPromoters.Add(projectDetailPromoter);

            var projectDetail = db.ProjectDetails.Find(input.ProjectDetailId);

            string totalTimeSpan = (projectDetail.Project.EndDate.Value - projectDetail.Project.StartDate).ToString();

            int totalDays = Convert.ToInt32(totalTimeSpan.Split('.')[0]);

            for (int i = 0; i <= totalDays; i++)
            {
                DailyPromoterPlan dailyPromoterPlan = new DailyPromoterPlan()
                {
                    Id = Guid.NewGuid(),
                    ProjectDetailPromoterId = projectDetailPromoter.Id,
                    ShiftDate    = projectDetail.Project.StartDate.AddDays(i),
                    CreationDate = DateTime.Now,
                    IsDeleted    = false,
                    IsActive     = true,
                };

                db.DailyPromoterPlans.Add(dailyPromoterPlan);
            }

            db.SaveChanges();
            return(RedirectToAction("index", new { id = input.ProjectDetailId }));
        }
示例#8
0
        public ActionResult Edit(DailyPromoterPlan dailyPromoterPlan)
        {
            if (ModelState.IsValid)
            {
                if (dailyPromoterPlan.StartHour == 0 && dailyPromoterPlan.StartMin == 0)
                {
                    dailyPromoterPlan.StartHour = null;
                    dailyPromoterPlan.StartMin  = null;
                }

                if (dailyPromoterPlan.FinishHour == 0 && dailyPromoterPlan.FinishMin == 0)
                {
                    dailyPromoterPlan.FinishHour = null;
                    dailyPromoterPlan.FinishMin  = null;
                }
                dailyPromoterPlan.IsDeleted       = false;
                db.Entry(dailyPromoterPlan).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = dailyPromoterPlan.ProjectDetailPromoterId }));
            }
            ViewBag.ProjectDetailPromoterId = dailyPromoterPlan.ProjectDetailPromoterId;
            return(View(dailyPromoterPlan));
        }