public ActionResult Create(TrialViewModel trialViewModel) { TrialModel trialModel = new TrialModel(); try { string uploadDirectory = "~/files/"; if (!Directory.Exists(Server.MapPath(uploadDirectory))) { Directory.CreateDirectory(Server.MapPath(uploadDirectory)); } string fileRelativePath = uploadDirectory + trialViewModel.TrialName + "_" + Path.GetFileName(trialViewModel.StudyFacts.FileName); string path = Path.Combine(Server.MapPath(fileRelativePath)); trialViewModel.DocumentUrl = fileRelativePath; trialViewModel.DocumentHash = Utility.GetHash(trialViewModel.StudyFacts.InputStream); trialViewModel.StudyFacts.SaveAs(path); trialViewModel.StudyFacts = null; //populate trial-model by trial-view-model trialModel = GetTrialModel(trialViewModel); var info = GetMultiChainClient().PublishStream(GetTrialStream(), trialModel.TrialName, trialModel.TrialData); info.AssertOk(); return(RedirectToAction("Index", "Home")); } catch (Exception ex) { ViewBag.Error = ex.ToString(); return(View()); } }
public ActionResult Create(FormCollection collection) { TrialModel trialModel = new TrialModel(); try { MultiChainClient mcClient = new MultiChainClient("54.234.132.18", 2766, false, "multichainrpc", "testmultichain", "TrialRepository"); //populate trial-model by trial-view-model trialModel = GetTrialModel(collection); //Keep following line commented till the time GetTrialModel implemented. var info = mcClient.ListStreamItems("TrialStream"); //var info = mcClient.PublishStream("TrialStream", trialModel.TrialKey, trialModel.TrialData); info.AssertOk(); return(RedirectToAction("Index", "Home")); } catch { return(View()); } }
public async Task <ActionResult> Edit(TrialModel trial) { if (ModelState.IsValid) { var entity = trial.ToEntity(); _trialService.Update(entity); return(RedirectToAction("Index")); } return(View(trial)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Status,StartDate,EndDate,StudyType,InterventionType,Phase")] TrialModel trial) { if (ModelState.IsValid) { var entity = trial.ToEntity(); _trialService.New(entity); return(RedirectToAction("Index")); } return(View(trial)); }
public static Trial ToEntity(this TrialModel obj) { Trial trial = new Trial(); trial.EndDate = obj.EndDate; trial.InterventionType = obj.InterventionType; trial.Phase = obj.Phase; trial.StartDate = obj.StartDate; trial.Status = obj.Status; trial.Id = obj.Id; trial.IsDeleted = obj.IsDeleted; trial.StudyType = obj.StudyType; return(trial); }
private void SendTrialEmail(User user, string activationCode, Company company) { var license = company.Licenses.FirstOrDefault(); var days = (int)Math.Round(license.Return(x => x.ExpiryDate.Subtract(DateTime.Today), new TimeSpan(45, 0, 0, 0)).TotalDays); var model = new TrialModel(this.Settings) { CompanyName = company.CompanyName, MailSubject = Emails.TrialSubject, TrialContactEmail = (string)this.Settings.TrialContactEmail, TrialDays = days, UserName = user.Email, ActivationCode = activationCode, FirstName = user.FirstName }; var bcced = new List <MailAddress> { new MailAddress(this.Settings.TrialContactEmail), new MailAddress(Common.JacquieEmail, Common.JacquieName) }; bool sentSuccessfully = this.MailModel.SendEmailSync( user.FirstName, user.Email, Emails.TrialSubject, model, Common.AppEmailName, Common.AppEmail, bcced: bcced); this.SaveHistory( sentSuccessfully, user.FirstName, user.Email, Emails.TrialSubject, model, Common.AppEmailName, Common.AppEmail, bcced: bcced); }