public ActionResult Index(string job, string name, string motto) { List <Models.project> list = new List <Models.project>(); var item = new Models.project(); item.job = "組長"; item.name = "李益銘"; item.motto = "The Best Of The Men At Work"; list.Add(item); var item2 = new Models.project(); item2.job = "組員"; item2.name = "方光明"; item2.motto = "Black Light Syndrome"; list.Add(item2); ViewBag.ListDatas = list; var item3 = new Models.project(); item3.job = "組員"; item3.name = "張維哲"; item3.motto = "Everything ought to be beautiful in a human being: face, dress, soul and idea"; list.Add(item3); ViewBag.ListDatas = list; var item4 = new Models.project(); item4.job = "組員"; item4.name = "柯軒安"; item4.motto = "When an opportunity is neglected,it never comes back to you"; list.Add(item4); ViewBag.ListDatas = list; var item5 = new Models.project(); item5.job = "組員"; item5.name = "王偉鈞"; item5.motto = "Have but few friends, though many acquaintances"; list.Add(item5); ViewBag.ListDatas = list; return(View()); }
public ActionResult assignPMtoProject(int pm_id, int post_id) // in profile page /* choose one pm and then go to another page to create group then it * is deleted from posts table but added to project table*/ { var postinstance = db.posts.Find(post_id); var pminstance = db.posts.Find(pm_id); if (postinstance != null && pminstance != null) { var value1 = from d in db.posts where d.id == post_id select d; // post record var data_post = value1.ToList(); var value2 = from d in db.requestProjects where d.PMs_id == pm_id && d.post_id == post_id select d; // request of project records var data_request_project = value2.ToList(); var value3 = from d in db.PMS where d.id == pm_id select d.user_id; // pm id in user table Models.project proj = new Models.project() { user_id = Convert.ToInt32(value3), title = data_post[0].title, description = data_post[0].description, state = 0, price = data_request_project[0].price, project_remove = 0, start_date = DateTime.Now, end_date = DateTime.Today.AddDays(data_request_project[0].duration.Day) }; db.projects.Add(proj); db.SaveChanges(); var value4 = db.projects.Max(d => d.id); Models.request req = new Models.request() { PM_id = Convert.ToInt32(value3), user_id = data_post[0].user_id, project_id = value4, url = null, request_state = 0, }; db.requests.Add(req); db.SaveChanges(); } var delpost = db.posts.Find(post_id); if (delpost != null) { // delete the record of the post that is changed to project db.posts.Remove(delpost); db.SaveChanges(); } return(View()); }