Esempio n. 1
0
        public ActionResult NewLink(string universityCode, string studentId, NewLinkViewModel model)
        {
            if (ModelState.IsValid)
            {
                db.StudentLinks.Add(new StudentLinkToOtherEI
                {
                    StudentId = model.InstitutionStudentID,
                    EICode    = model.SelectedInstitute,
                    Status    = LinkApprovalStatusEnum.PendingApproval
                });
                db.SaveChanges();

                return(Student(universityCode, studentId));
            }
            else
            {
                model.Student    = db.Students.First(s => s.EducationalInstitute.Code == universityCode && s.StudentId == studentId);
                model.Institutes = db.EducationalInstitutes.Select(ei => new SelectListItem
                {
                    Text  = ei.Name,
                    Value = ei.Code
                }).ToArray();

                return(View(model));
            }
        }
Esempio n. 2
0
 public IActionResult NewLink(NewLinkViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Repository.CreateNewLink(vm.LinkToAdd);
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         return(View(vm));
     }
 }
        public async Task <IActionResult> Create([FromForm] NewLinkViewModel viewModel, CancellationToken ct)
        {
            var link = new Link
            {
                Url       = viewModel.Url,
                Title     = viewModel.Title,
                User      = User.FindFirst(BobbinsClaimTypes.ScreenName).Value,
                CreatedAt = DateTimeOffset.UtcNow,
            };

            link = await _links.Create(link, ct).ConfigureAwait(false);

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind(Prefix = "NewLink")] NewLinkViewModel model)
        {
            // try
            // {
            var link = new ShortLink
            {
                Key            = Guid.NewGuid().ToString().Substring(0, 7),
                DestinationUrl = model.DestinationUrl,
                Created        = DateTime.UtcNow
            };

            await _dbContext.SaveAsync <ShortLink>(link);

            return(RedirectToAction(nameof(Index)));
            // }
            // catch(exce)
        }