public async Task<Job> CreateJob(CreateJobInput input) { //We can use Logger, it's defined in ApplicationService class. Logger.Info("Creating a job for input: " + input); //Creating a new Task entity with given input's properties var job = new Job { Description = input.Description, Detail = input.Detail, AccountId = input.AccountId, Type = input.Type, AssignedUserId = input.AssignedUserId , PrimaryContactId = input.PrimaryContactId, Source = input.Source, Priority = input.Priority}; job.PrimaryContact = _contactRepository.Get((long)job.PrimaryContactId); job.Account = _accountRepository.Get((long)job.AccountId); job.AssignedUser = await _userManager.FindByIdAsync((long)job.AssignedUserId); //TODO: Complete creating an external Job in SLX string createdUserId = (await _userManager.FindByIdAsync((long)AbpSession.UserId)).ExternalId; ///Update in External System (Saleslogix if enabled) String result = CreateExternal(job.Account.ExternalId,job.PrimaryContact.ExternalId,createdUserId,job.AssignedUser.ExternalId,job.Description,job.Detail,"",job.Priority.ToString(),job.Source.ToString()); job.ExternalId = result; //Saving entity with standard Insert method of repositories. return await _jobRepository.InsertAsync(job); }
// GET: Jobs/Create public ActionResult Create() { CreateJobInput createjobinput = new CreateJobInput(); var users = _svcUser.GetUsers().Users .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.DisplayName }); ; createjobinput.AssignedUserSelectList = new SelectList(users, "Value", "Text"); return View(createjobinput); }