예제 #1
0
        private CooperatorService CreateCooperatorService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CooperatorService(userId);

            return(service);
        }
예제 #2
0
        public ActionResult CompleteRequest(int id)
        {
            var userId      = Guid.Parse(User.Identity.GetUserId());
            var coopService = new CooperatorService(userId);

            ViewBag.cooperators = coopService.GetCooperators(userId).Where(e => e.ContactType == contact.Employee);

            var locService = new LocationService(userId);

            ViewBag.locations = locService.GetLocations(userId);

            var service = CreateMessageService();
            var detail  = service.GetMessageEditById(id, userId);
            var model   = new MessageEdit
            {
                MessageId        = detail.MessageId,
                LocationId       = detail.LocationId,
                LocationCode     = detail.LocationCode,
                Comment          = detail.Comment,
                CooperatorId     = detail.CooperatorId,
                DateCreated      = detail.DateCreated,
                OwnerId          = detail.OwnerId,
                JobOne           = detail.JobOne,
                JobTwo           = detail.JobTwo,
                JobThree         = detail.JobThree,
                IsRequest        = detail.IsRequest,
                HumanGrowthStage = detail.HumanGrowthStage,
                Rating           = detail.Rating
            };

            return(View(model));
        }
        public ActionResult EditCoop(int id)
        {
            var userId      = Guid.Parse(User.Identity.GetUserId());
            var coopService = new CooperatorService(userId);

            ViewBag.cooperators = coopService.GetCooperators(userId).Where(e => e.ContactType == contact.Cooperator);

            var service = CreateLocationService();
            var detail  = service.GetLocationEditById(id, userId);
            var model   = new LocationEdit
            {
                LocationId      = detail.LocationId,
                LocationName    = detail.LocationName,
                State           = detail.State,
                LocationCode    = detail.LocationCode,
                Longitude       = detail.Longitude,
                Latitude        = detail.Latitude,
                MonthOfPlanting = detail.MonthOfPlanting,
                DayOfPlanting   = detail.DayOfPlanting,
                YearOfPlanting  = detail.YearOfPlanting,
                IsStaked        = detail.IsStaked,
                CooperatorId    = detail.CooperatorId,
                FullName        = detail.FullName
            };

            return(View(model));
        }
예제 #4
0
        public ActionResult Details(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CooperatorService(userId);
            var model   = service.GetCooperatorById(id, userId);

            return(View(model));
        }
예제 #5
0
        public ActionResult DeletePost(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CooperatorService(userId);

            service.DeleteCooperator(id, userId);

            return(RedirectToAction("Index"));
        }
예제 #6
0
 public ActionResult Create(CooperatorCreate model)
 {
     if (ModelState.IsValid)
     {
         var service = new CooperatorService(Guid.Parse(User.Identity.GetUserId()));
         var result  = service.CreateCooperator(model);
         TempData["SaveResult"] = "New cooperator successfully created.";
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
예제 #7
0
        public ActionResult Create()
        {
            var userId     = Guid.Parse(User.Identity.GetUserId());
            var locService = new LocationService(userId);

            ViewBag.locations = locService.GetLocations(userId);

            var coopService = new CooperatorService(userId);

            ViewBag.cooperators = coopService.GetCooperators(userId).Where(e => e.ContactType == contact.Employee);

            return(View());
        }
        public ActionResult Edit(int id)
        {
            var userId      = Guid.Parse(User.Identity.GetUserId());
            var coopService = new CooperatorService(userId);

            ViewBag.cooperators = coopService.GetCooperators(userId);

            var messageService = new MessageService(userId);

            ViewBag.messages = messageService.GetMessages(id, userId);

            var documentService = new DocumentService(userId);

            ViewBag.documents = documentService.GetDocuments(id, userId);

            var service = CreateLocationService();
            var detail  = service.GetLocationEditById(id, userId);
            var model   = new LocationEdit
            {
                LocationId      = detail.LocationId,
                LocationName    = detail.LocationName,
                State           = detail.State,
                LocationCode    = detail.LocationCode,
                Longitude       = detail.Longitude,
                Latitude        = detail.Latitude,
                MonthOfPlanting = detail.MonthOfPlanting,
                DayOfPlanting   = detail.DayOfPlanting,
                YearOfPlanting  = detail.YearOfPlanting,
                CooperatorId    = detail.CooperatorId,
                FullName        = detail.FullName,
                CRM             = detail.CRM,
                Messages        = detail.Messages,
                Documents       = detail.Documents,
                Tag             = detail.Tag,
                SearchString    = detail.SearchString,
                DatePlanted     = detail.DatePlanted,
                DateHarvested   = detail.DateHarvested,
                IsPlanted       = detail.IsPlanted,
                IsRowbanded     = detail.IsRowbanded,
                IsStaked        = detail.IsStaked,
                IsHarvested     = detail.IsHarvested,
                DocString       = detail.DocString,
                Rating          = detail.Rating,
                MapLink         = "https://www.google.com/maps/dir/?api=1&destination=" + detail.Latitude + "," + detail.Longitude
            };

            return(View(model));
        }
예제 #9
0
        public ActionResult Edit(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CooperatorService(userId);
            var detail  = service.GetCooperatorById(id, userId);
            var model   = new CooperatorEdit
            {
                CooperatorId = detail.CooperatorId,
                FirstName    = detail.FirstName,
                LastName     = detail.LastName,
                Phone        = detail.Phone,
                Email        = detail.Email,
                ContactType  = detail.ContactType,
                OwnerId      = detail.OwnerId
            };

            return(View(model));
        }
예제 #10
0
        public ActionResult CreateRequest(MessageCreate model)
        {
            var userId      = Guid.Parse(User.Identity.GetUserId());
            var coopService = new CooperatorService(userId);

            ViewBag.cooperators = coopService.GetCooperators(userId).Where(e => e.ContactType == contact.Employee);

            var locService = new LocationService(userId);

            ViewBag.locations = locService.GetLocations(userId);

            if (ModelState.IsValid)
            {
                var service = new MessageService(Guid.Parse(User.Identity.GetUserId()));
                var result  = service.CreateRequest(model);
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
예제 #11
0
        // GET: Cooperator
        public ActionResult Index(string searchString, string toggleView)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CooperatorService(userId);
            var model   = service.GetCooperators(userId);

            model.OrderBy(s => s.LastName);

            ViewBag.ToggleView   = "viewOne";
            ViewBag.SearchString = searchString;

            if (toggleView != null)
            {
                ViewBag.ToggleView = toggleView;
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                model = model.Where(e => e.SearchString.Contains(searchString.ToUpper()));
            }

            return(View(model.OrderBy(e => e.FullName)));
        }
예제 #12
0
        public ActionResult Edit(int id, CooperatorEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.CooperatorId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CooperatorService(userId);

            if (service.UpdateCooperator(model, userId))
            {
                TempData["SaveResult"] = "Your cooperator was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your cooperator could not be updated.");
            return(View(model));
        }