public ActionResult Create([Bind(Include = "Id,ProjectId,ReportNumber,ScheduledDate,PerformedDate,Auditor,Comments,BaselineId")] AuditsViewModel auditViewModel) { if (ModelState.IsValid) { var audit = new Audits() { Auditor = auditViewModel.Auditor, BaselineId = auditViewModel.BaselineId, Project = auditViewModel.Project, PerformedDate = auditViewModel.PerformedDate, Comments = auditViewModel.Comments, BaselinePlan = auditViewModel.BaselinePlan, ProjectId = auditViewModel.ProjectId, ReportNumber = auditViewModel.ReportNumber, ScheduledDate = auditViewModel.ScheduledDate }; db.Audits.Add(audit); db.SaveChanges(); return(RedirectToAction("Index")); } var projects = db.ProjectUser.Where(pu => pu.UserName.Trim() == User.Identity.Name).Select(pu => pu.Project); ViewBag.BaselineId = new SelectList(db.BaselinePlan.Where(b => b.ProjectId == auditViewModel.ProjectId), "Id", "Name"); ViewBag.ProjectId = new SelectList(projects, "Id", "Name", auditViewModel.ProjectId); return(View(auditViewModel)); }
public ActionResult Create(GitSetupViewModel viewModel, string returnUrl) { var projects = db.ProjectUser.Where(pu => pu.UserName.Trim() == User.Identity.Name).Select(pu => pu.Project); ViewBag.ProjectsList = new SelectList(projects.ToList(), "Id", "Name"); if (ModelState.IsValid) { try { //if (CheckGitSetup(viewModel)) //{ // Save Data var gitModel = new GitSetup() { RepositoryPath = viewModel.RepositoryPath.Trim(), ProjectId = viewModel.Project.Id, Crendential = new Crypt32().Encrypt(Crypt32.KeyType.UserKey, viewModel.UserName + "|" + viewModel.Password), Description = viewModel.Description }; db.GitSetup.Add(gitModel); db.SaveChanges(); return(RedirectToAction("Index")); //} } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } return(View()); }
public async Task <ActionResult> Create(TeamCityViewModel viewModel, string returnUrl) { var projects = db.ProjectUser.Where(pu => pu.UserName.Trim() == User.Identity.Name).Select(pu => pu.Project); viewModel.ProjectList = new SelectList(projects.ToList(), "Id", "Name"); viewModel.BuildIdsList = new SelectList(new List <string>()); if (ModelState.IsValid) { try { if (CheckTeamCitySetup(viewModel)) { // Save Data var teamCityModel = new TeamCitySetup() { Uri = viewModel.URI.Trim(), Crendential = new Crypt32().Encrypt(Crypt32.KeyType.UserKey, viewModel.UserName + ";" + viewModel.Password), IdProject = viewModel.Project.Id, BuildId = viewModel.BuildId }; db.TeamCitySetup.Add(teamCityModel); db.SaveChanges(); TempData["Success"] = "Yes"; return(RedirectToAction("Index")); } } catch (WebException e) { if (e.Response != null) { using (WebResponse response = e.Response) { var httpResponse = (HttpWebResponse)response; if (httpResponse.StatusCode == HttpStatusCode.Unauthorized) { ModelState.AddModelError(string.Empty, "Invalid username or password."); } else { ModelState.AddModelError(string.Empty, "Cannot establish connection with this server."); } } } else { ModelState.AddModelError(string.Empty, "Cannot establish connection with this server."); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } return(View(viewModel)); }
public ActionResult Create([Bind(Include = "Id,Username,Password,Role,IsActive")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "Id,ClassId,Datetime,Status")] ClassSchedule classSchedule) { if (ModelState.IsValid) { db.ClassSchedules.Add(classSchedule); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassId = new SelectList(db.Classes, "Id", "Name", classSchedule.ClassId); return(View(classSchedule)); }
public ActionResult Create([Bind(Include = "Id,StudentId,ClassId")] Studying studying) { if (ModelState.IsValid) { db.Studyings.Add(studying); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassId = new SelectList(db.Classes, "Id", "Name", studying.ClassId); ViewBag.StudentId = new SelectList(db.Students, "Id", "Name", studying.StudentId); return(View(studying)); }
public ActionResult Create([Bind(Include = "Id,SubjectId,TeacherId,Name,Day,StartSession,QuantityOfSession,Room")] Class @class) { if (ModelState.IsValid) { db.Classes.Add(@class); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubjectId = new SelectList(db.Subjects, "Id", "Name", @class.SubjectId); ViewBag.TeacherId = new SelectList(db.Teachers, "Id", "Name", @class.TeacherId); return(View(@class)); }
public ActionResult Create([Bind(Include = "Id,Name,PhoneNumber,Address,Email,FacultyId,UserId,Gender,Hometown,Birthday")] Teacher teacher) { if (ModelState.IsValid) { db.Teachers.Add(teacher); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FacultyId = new SelectList(db.Faculties, "Id", "Name", teacher.FacultyId); ViewBag.UserId = new SelectList(db.Users, "Id", "Username", teacher.UserId); return(View(teacher)); }
/// <summary> /// Remove the flight /// </summary> /// <param name="Id"></param> public virtual void Remove(int Id) { Flight flight = EntitiesDB.FlightSet.Find(Id); EntitiesDB.FlightSet.Remove(flight); EntitiesDB.SaveChanges(); }
public ActionResult Edit(BaselineFlowListViewModel baselineFlowListViewModel) { var flows = GetBaselineFlowsModel(baselineFlowListViewModel.PostedBaselineFlows); db.BaselineFlowProject.RemoveRange( db.BaselineFlowProject.Where(p => p.ProjectId == baselineFlowListViewModel.Project.Id)); foreach (var baselineFlow in flows.SelectedBaselineFlow) { var flowProject = new BaselineFlowProject() { BaselineFlowId = baselineFlow.Id, ProjectId = baselineFlowListViewModel.Project.Id }; db.BaselineFlowProject.Add(flowProject); } db.SaveChanges(); TempData["Success"] = "Saved with success. "; return(View(flows)); }
public ActionResult Create([Bind(Include = "Id,BaselinePlanId,Values")] BaselinePlanAuditViewModel viewModel) { if (ModelState.IsValid) { var baselinePlanAudit = new BaselinePlanAudit(); baselinePlanAudit.BaselinePlanId = viewModel.BaselinePlanId; baselinePlanAudit.Values = string.Join(",", viewModel.Values); baselinePlanAudit.Verified = true; db.BaselinePlanAudit.Add(baselinePlanAudit); db.SaveChanges(); return(RedirectToAction("Index")); } var projects = db.ProjectUser.Where(pu => pu.UserName.Trim() == User.Identity.Name).Select(pu => pu.Project); var baselinePlans = db.BaselinePlan.Where(bp => projects.Contains(bp.Project)); ViewBag.BaselinePlanId = new SelectList(baselinePlans, "Id", "Name", viewModel.BaselinePlanId); return(View(viewModel)); }
/// <summary> /// Modified the flight /// </summary> /// <param name="flight"></param> public virtual void Change(Flight flight) { flight.SourceAirportName = flight.Source.Name; flight.DestinationAirportName = flight.Destination.Name; flightDomain.FlightCalculator(flight); EntitiesDB.Entry(flight).State = EntityState.Modified; EntitiesDB.SaveChanges(); }
/// <summary> /// Add a new flight /// </summary> /// <param name="flight"></param> /// <returns></returns> public virtual Flight Add(Flight flight) { flight.SourceAirportName = flight.Source.Name; flight.DestinationAirportName = flight.Destination.Name; flightDomain.FlightCalculator(flight); EntitiesDB.FlightSet.Add(flight); EntitiesDB.SaveChanges(); return(flight); }
public ActionResult Create(BaselinePlanViewModel viewModel) { var projects = db.ProjectUser.Where(pu => pu.UserName.Trim() == User.Identity.Name).Select(pu => pu.Project); ViewBag.ProjectsList = new SelectList(projects.ToList(), "Id", "Name"); if (ModelState.IsValid) { try { // Save Data var baselinePlan = new BaselinePlan() { Name = viewModel.Name, Description = viewModel.Description, ProjectId = viewModel.Project.Id, IsReleased = viewModel.IsReleased, ReleaseDate = viewModel.ReleaseDate, RememberMe = viewModel.RememberMe, RememberMeDays = viewModel.RememberMeDays }; db.BaselinePlan.Add(baselinePlan); db.SaveChanges(); TempData["Success"] = "Yes"; return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } return(View()); }
public ActionResult Create(Project model, string teamList) { try { if (ModelState.IsValid) { db.Project.Add(model); db.SaveChanges(); SaveProjectUsers(model, teamList); return(RedirectToAction("Index")); } return(View(model)); } catch { return(View()); } }