public async Task <ActionResult> SendComment(string code, ShowSpecialityModel model) { if (code.Length == 2) { code = '0' + code; } if (ModelState.IsValid) { await dbSpec.CreateComment(new Comment_Speciality { AuthorsEmail = User.Identity.Name, Text = model.NewComment, Date = DateTime.UtcNow, Code = code }); return(RedirectToAction("ShowSpeciality", "Home", new { code })); } return(View(model)); }
public async Task <ActionResult> ShowSpeciality(string code) { ShowSpecialityModel model = null; Speciality s = await dbSpec.GetSpecialityCode(code); List <Speciality_Subject> subjs = await dbSpec.GetSpecialitySubjs(code); List <Speciality_Proffesion> proffs = await dbSpec.GetSpecialityProffs(code); List <Comment_Speciality> comms = await dbSpec.GetComments(code); if (code[0] == '0') { code = code.Substring(1); } model = new ShowSpecialityModel { Code = code, Name = s.Name, Introduction = s.Introduction, Content = s.Content, ImageId = s.ImageId, Link = s.Link }; if (subjs != null) { model.Subjects = new string[subjs.Count]; for (int i = 0; i < subjs.Count; i++) { model.Subjects[i] = subjs[i].Subject; } } if (proffs != null) { model.Jobs = new string[proffs.Count]; for (int i = 0; i < proffs.Count; i++) { model.Jobs[i] = proffs[i].Proffesion; } } if (comms != null) { comms.Reverse(); model.Comments = comms.ToArray(); for (int i = 0; i < model.Comments.Length; i++) { model.Comments[i].HasImage = (await db.GetUserE(model.Comments[i].AuthorsEmail)).HasImage(); model.Comments[i].Name = (await db.GetUserE(model.Comments[i].AuthorsEmail)).Name; } } model.Likes = dbSpec.GetLikesCount(code); return(View(model)); }
public async Task <ActionResult> Speciality(ShowSpecialityModel model) { return(View(model)); }