Beispiel #1
0
        public ActionResult Edit(int id)
        {
            var cRMPotential = _crmPotentialRepository.Get(id);

            ViewBag.CategoryId       = new SelectList(_crmPotentialCategoryRepository.GetAll(), "Id", "Title", cRMPotential.CategoryId);
            ViewBag.AssignedToUserId = new SelectList(_userRepository.GetAll("Person"), "Id", "Person.Name", cRMPotential.AssignedToUserId);
            ViewBag.ContactId        = new SelectList(_crmContactRepository.GetAll("Person"), "Id", "Person.Name", cRMPotential.ContactId);
            ViewBag.SalesStageId     = new SelectList(_crmSalesStageRepository.GetAll(), "Id", "Name", cRMPotential.SalesStageId);

            return(View(cRMPotential));
        }
Beispiel #2
0
        public ActionResult Edit(int id)
        {
            if (!DoIHaveAccessToProject(id))
            {
                return(RedirectToAction("NotAuthorized", "Error", new { area = "" }));
            }

            var project = _projectRepository.Get(id);

            if (project == null)
            {
                return(HttpNotFound());
            }

            var mappedTechnologies = _projectTechnologyMapRepository.GetAllBy(m => m.ProjectId == project.Id).Select(m => m.TechnologyId).ToList();

            ViewBag.Technologies = new MultiSelectList(_technologyRepository.GetAll(), "Id", "Title", mappedTechnologies);
            ViewBag.ClientId     = new SelectList(_crmContactRepository.GetAll("Person"), "Id", "Person.Name", project.ClientId);
            ViewBag.ParentId     = new SelectList(_projectRepository.GetAll(), "Id", "Title", project.ParentId);

            var vm = new EditProjectViewModel(project);

            return(View(vm));
        }
Beispiel #3
0
        public JsonResult Index()
        {
            var apiResult = TryExecute(() => _crmContactRepository.GetAll(), "Contacts Fetched sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult Create(NewRequirementViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var requirement = new Requirement
                {
                    AssignedToUserId = vm.AssignedToUserId,
                    ContactId        = vm.ContactId,
                    SourceId         = vm.SourceId,
                    CategoryId       = vm.CategoryId,
                    Title            = vm.Title,
                    Description      = vm.Description,
                    Url               = vm.Url,
                    BillingType       = vm.BillingType,
                    Budget            = vm.Budget,
                    PostedOn          = vm.PostedOn.ToUniversalTime(),
                    RequirementStatus = RequirementStatus.New,
                    CreatedByUserId   = WebUser.Id
                };


                _requirementRepository.Create(requirement);
                _unitOfWork.Commit();

                // Map the Technologies
                if (vm.TechnologyIds != null)
                {
                    foreach (var technologyId in vm.TechnologyIds)
                    {
                        var newMap = new RequirementTechnologyMap
                        {
                            RequirementId = requirement.Id,
                            TechnologyId  = technologyId
                        };

                        _requirementTechnologyMapRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                // Add the activities
                var postedActivity = new RequirementActivity
                {
                    Title           = "Posted in Source",
                    Comment         = "Requirement was posted",
                    RequirementId   = requirement.Id,
                    CreatedOn       = requirement.PostedOn.ToUniversalTime(),
                    CreatedByUserId = WebUser.Id
                };

                _requirementActivityRepository.Create(postedActivity);

                var createdActivity = new RequirementActivity
                {
                    Title           = "Created",
                    Comment         = WebUser.Name + " created the requirement in Grid",
                    RequirementId   = requirement.Id,
                    CreatedByUserId = WebUser.Id
                };

                _requirementActivityRepository.Create(createdActivity);

                _unitOfWork.Commit();


                // Send Email, Email Template name is hard corded - Need to change later
                // Replace the hard coded emails with settings or a team.
                #if !DEBUG
                _emailComposerService.SendNewRequirementEmail(requirement.Id);
                #endif

                return(RedirectToAction("Details", "Requirements", new { id = requirement.Id }));
            }

            ViewBag.Technologies     = new MultiSelectList(_technologyRepository.GetAll(), "Id", "Title", vm.TechnologyIds);
            ViewBag.AssignedToUserId = new SelectList(_userRepository.GetAll("Person"), "Id", "Person.Name", vm.AssignedToUserId);
            ViewBag.ContactId        = new SelectList(_crmContactRepository.GetAll("Person"), "Id", "Person.Name", vm.ContactId);
            ViewBag.CategoryId       = new SelectList(_requirementCategoryRepository.GetAll(), "Id", "Title", vm.CategoryId);
            ViewBag.SourceId         = new SelectList(_crmLeadSourceRepository.GetAll(), "Id", "Title", vm.SourceId);

            return(View(vm));
        }