コード例 #1
0
ファイル: SectionService.cs プロジェクト: hosam00/luxorna
        public SectionEditViewModel Update(SectionEditViewModel Section)
        {
            Section _Section = SectionRepo.Update(Section.toModel());

            unitOfWork.commit();
            return(_Section.toEditViewModel());
        }
コード例 #2
0
        public async Task <IActionResult> Create()
        {
            var viewModel = new SectionEditViewModel
            {
                Departments = await _employeeDetailService.GetDepartments()
            };

            return(View(viewModel));
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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 }));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
ファイル: SectionService.cs プロジェクト: hosam00/luxorna
 public void Remove(SectionEditViewModel Section)
 {
     SectionRepo.Remove(Section.toModel());
     unitOfWork.commit();
 }
コード例 #9
0
        public SectionEditViewModel EditSection(SectionEditViewModel SectionEditView)
        {
            var Section = SectionService.Update(SectionEditView);

            return(Section);
        }
コード例 #10
0
        public SectionEditViewModel AddSection(SectionEditViewModel SectionEditView)
        {
            var Section = SectionService.Add(SectionEditView);

            return(Section);
        }