public async Task <IActionResult> AddComment(RegisterModalClientViewModal data) { var department = _context.Department.FirstOrDefault(m => m.DepartmentId == data.DepartmentIdCommentSelected); department.Comments = data.DepartmentComment; if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.DepartmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } TempData["ErrorMsg"] = "No se puede añadir comentario"; return(RedirectToAction("Index", "Departments")); }
public async Task <IActionResult> Index() { var user = HttpContext.Session.GetString("User"); UserData dataItem = JsonConvert.DeserializeObject <UserData>(user.ToString()); RegisterModalClientViewModal model = new RegisterModalClientViewModal { Departments = await _context.Department.Include(d => d.DepartmentState).Include(d => d.DepartmentType).ToListAsync() }; return(View(model)); }
public IActionResult RegisterClient(RegisterModalClientViewModal data) { if (ModelState.IsValid) { var user = HttpContext.Session.GetString("User"); UserData dataItem = JsonConvert.DeserializeObject <UserData>(user.ToString()); var idUser = dataItem.CommisionerId; var exist = _context.Client.FirstOrDefault(m => m.CI == data.Client.CI); if (exist == null) { string ClientJson = JsonConvert.SerializeObject(data.Client, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(RedirectToAction("RegisterCreate", "Visitregistrations", new { clientJson = ClientJson, idCommisioner = idUser, idDepartment = data.DepartmentIdSelected })); } } TempData["ErrorMsg"] = "Cliente ya registrado"; return(RedirectToAction("Index", "Departments")); }