public SectionEditViewModel Update(SectionEditViewModel Section) { Section _Section = SectionRepo.Update(Section.toModel()); unitOfWork.commit(); return(_Section.toEditViewModel()); }
public async Task <IActionResult> Create() { var viewModel = new SectionEditViewModel { Departments = await _employeeDetailService.GetDepartments() }; return(View(viewModel)); }
public async Task <IActionResult> Create(SectionEditViewModel model) { if (ModelState.IsValid) { var section = new SectionModel { DepartmentId = model.DepartmentId, SectionName = model.SectionName, SectionCode = model.SectionCode }; await _sectionService.AddAsync(section); return(RedirectToAction(nameof(Index))); } return(View()); }
public ActionResult Delete(int?id, string mensaje) { ViewBag.Status = false; if (mensaje != null && mensaje != "") { if (mensaje == "Ok") { ViewBag.Message = "Dominio Eliminado exitosamente"; ViewBag.Status = true; } else { ViewBag.Message = mensaje; ViewBag.Status = false; } } try { var oSection = new SectionEditViewModel(); using (BD_EvaluacionEntities Db = new BD_EvaluacionEntities()) { oSection = (from secc in Db.Secciones where secc.Id == id select new SectionEditViewModel { Id = secc.Id, Codigo_Seccion = secc.Codigo_Seccion, Nombre_Seccion = secc.Nombre_Seccion, Ponderacion_S = secc.Ponderacion_S ?? 0, IdState = secc.IdState }).FirstOrDefault(); } ViewBag.DomState = new SelectList(Tools.LeerEstados(), "IdState", "StateDescription", 3); return(View(oSection)); } catch (Exception ex) { Mensaje = ex.InnerException.InnerException.Message + "Contactar al administrador"; return(View(id.ToString(), Mensaje)); } }
public async Task <IActionResult> Edit(int id) { var section = await _sectionService.GetByIdAsync(id); if (section == null) { return(NotFound()); } var editViewModel = new SectionEditViewModel { SectionId = section.SectionId, DepartmentId = section.DepartmentId, SectionName = section.SectionName, SectionCode = section.SectionCode, Departments = await _employeeDetailService.GetDepartments() }; return(View(editViewModel)); }
public ActionResult Delete(SectionEditViewModel svm) { try { if (!ValidaDominios(svm.Codigo_Seccion)) { if (ModelState.IsValid) { using var bd = new BD_EvaluacionEntities(); var oUser = bd.Secciones.Find(svm.Codigo_Seccion); oUser.IdState = 3; bd.Entry(oUser).State = System.Data.Entity.EntityState.Modified; bd.SaveChanges(); Mensaje = "Ok"; } else { string errors = string.Empty; foreach (var item in ModelState.Values) { if (item.Errors.Count > 0) { Mensaje += string.Format("{0} \n", item.Errors[0].ErrorMessage); } Mensaje += " Contacte al Administrador"; } } } else { Mensaje = "Este dominio tiene preguntas asociadas, No se puede eliminar"; } } catch (Exception ex) { Mensaje = ex.InnerException.InnerException.Message + "Contactar al administrador"; } return(RedirectToAction("Delete", "Section", new { id = svm.Id, Mensaje })); }
public async Task <IActionResult> Edit(int id, SectionEditViewModel model) { if (id != model.Id) { return(NotFound()); } var section = _context.Sections.FirstOrDefault(c => c.Id == model.Id); if (section == null) { return(NotFound()); } if (ModelState.IsValid) { section.Name = model.Name; section.Descriptions = model.Description; try { _context.Update(section); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SectionExists(section.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { section.Id })); } ViewData["currentProyect"] = section.ProyectId; return(View(model)); }
public void Remove(SectionEditViewModel Section) { SectionRepo.Remove(Section.toModel()); unitOfWork.commit(); }
public SectionEditViewModel EditSection(SectionEditViewModel SectionEditView) { var Section = SectionService.Update(SectionEditView); return(Section); }
public SectionEditViewModel AddSection(SectionEditViewModel SectionEditView) { var Section = SectionService.Add(SectionEditView); return(Section); }