public void ShouldMapGivingCertificateForUser() { const int SpecId = 3; const string UserId = "1DFA-126DAC-91E3F-AB918"; var certificate = new CertificateInputModel() { SpecialtyId = SpecId, UserId = UserId }; this.routeCollection .ShouldMap("/Public/Certificates/GiveCertificate") .WithFormUrlBody($"SpecialtyId={ SpecId }&userId={ UserId }") .To<CertificatesController>(c => c.GiveCertificate(certificate)); }
public ActionResult GiveCertificate(CertificateInputModel model) { this.UserManagement.EnsureFolder(model.UserId); string path = this.UserManagement.GetCurrentUserDirecotry(model.UserId); this.certificatesService.GiveToPerson( model.UserId, model.SpecialtyId, System.IO.Path.Combine(path, "Uploads"), Server.MapPath(WebConstants.PathToCertificate)); return this.RedirectToAction( "Students", "Specialties", new { id = model.SpecialtyId, area = "Trainer" }); }
public ActionResult GiveCertificateToAll(CertificateInputModel model) { var specialty = this.specialtiesService.GetAll().FirstOrDefault(s => s.Id == model.SpecialtyId); foreach (var student in specialty.Students) { this.UserManagement.EnsureFolder(student.Id); string path = this.UserManagement.GetCurrentUserDirecotry(student.Id); this.certificatesService.GiveToPerson( student.Id, specialty.Id, System.IO.Path.Combine(path, "Uploads"), Server.MapPath(WebConstants.PathToCertificate)); } return this.RedirectToAction( "Students", "Specialties", new { id = model.SpecialtyId, area = "Trainer" }); }