public async Task <IActionResult> Edit(Guid id, [Bind("ID,CandidateEndDate,CandidateId,CandidateJobDuties,CandidateStartDate,CreatedDate,Enabled,LastModifiedDate,RefereeEmail,RefereeEmployer,RefereeName,RefereeTelephone,RefereeTitle")] ReferenceRequest referenceRequest)
        {
            if (id != referenceRequest.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(referenceRequest);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReferenceRequestExists(referenceRequest.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(referenceRequest));
        }
        /// <summary>
        /// Called to request a reference from certain label with IExposable parent with request being uniqueLoadID.
        /// </summary>
        /// <param name="label"></param>
        /// <param name="uniqueLoadId"></param>
        /// <exception cref="InvalidProgramException"></exception>
        public void RequestReference(string label, string uniqueLoadId)
        {
            if (Scribe.mode != LoadSaveMode.LoadingVars)
            {
                throw new InvalidProgramException("RequestReference called when Scribe.mode != LoadingVars.");
            }

            var request = new ReferenceRequest(uniqueLoadId, label, Scribe.loader.curParent);

            requestedReferences.Add(request);
        }
        public async Task <IActionResult> Create([Bind("ID,CandidateEndDate,CandidateId,CandidateJobDuties,CandidateStartDate,CreatedDate,Enabled,LastModifiedDate,RefereeEmail,RefereeEmployer,RefereeName,RefereeTelephone,RefereeTitle")] ReferenceRequest referenceRequest)
        {
            if (ModelState.IsValid)
            {
                var             store = new UserStore <ApplicationUser>(_context);
                ApplicationUser user  = await store.FindByNameAsync(User.Identity.Name);

                referenceRequest.ID               = Guid.NewGuid();
                referenceRequest.CreatedDate      = DateTime.Now;
                referenceRequest.Enabled          = true;
                referenceRequest.LastModifiedDate = DateTime.Now;
                referenceRequest.CandidateId      = user.Id;

                _context.Add(referenceRequest);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(referenceRequest));
        }