public JsonResult SaveCode(InspectionCodeDTO att)
        {
            try
            {
                att.Id_User = ((UserDTO)Session["userData"]).Id;
                SedesolServiceClient proxy = new SedesolServiceClient();
                att = proxy.SaveInspectionCode(att);
                List <InspectionCodeDTO> listCode = new List <InspectionCodeDTO>();

                if (att.Message == "SUCCESS")
                {
                    listCode = proxy.GetCodesByUserId(((UserDTO)Session["userData"]).Id);
                }

                string viewContent = ConvertViewToString("CodeList", listCode);
                return(Json(new { message = att.Message, PartialView = viewContent }));
                //return PartialView("AttendanceList", captureModel.Capture.AttendanceList);
            }
            catch (Exception ex)
            {
                //return PartialView("AttendanceList", null);
                return(Json(new { message = "ERROR" }));
            }
        }
示例#2
0
        public InspectionCodeDTO Save(InspectionCodeDTO dto)
        {
            try
            {
                using (SEDESOLEntities db = new SEDESOLEntities())
                {
                    INSPECTION_CODE insCode = db.INSPECTION_CODE.FirstOrDefault(v => v.InspectionCode == dto.InspectionCode && v.Id_User == dto.Id_User);
                    if (insCode != null)
                    {
                        dto.Message = "Se ha ingresado previamente el código generado.";
                    }
                    else
                    {
                        INSPECTION_CODE insCode2 = db.INSPECTION_CODE.FirstOrDefault(v => v.Id_Year == dto.Id_Year && v.Id_Month == dto.Id_Month && v.Id_User == dto.Id_User);
                        if (insCode2 != null)
                        {
                            dto.Message = "Se ha generado previamente un código para el año y mes seleccionados.";
                        }
                        else
                        {
                            GEN_CODE_DAY genCode = db.GEN_CODE_DAY.FirstOrDefault(x => x.Id_Month == dto.Id_Month && x.Id_Year == dto.Id_Year);
                            if (genCode == null)
                            {
                                dto.Message = "No se ha habilitado la generación de códigos para el mes y año seleccionados.";
                            }
                            else
                            {
                                DateTime dateToValidate = new DateTime(Convert.ToInt32(genCode.YEAR.Description), genCode.Id_Month, genCode.Day);

                                if (DateTime.Today < dateToValidate)
                                {
                                    dto.Message = "No se ha habilitado la generación de códigos para el mes y año seleccionados.";
                                }
                                else
                                {
                                    INSPECTION_CODE insEntity = new INSPECTION_CODE
                                    {
                                        Id_Month       = dto.Id_Month,
                                        Id_Year        = dto.Id_Year,
                                        Id_User        = dto.Id_User,
                                        InspectionCode = dto.InspectionCode
                                    };

                                    db.INSPECTION_CODE.Add(insEntity);
                                    if (db.SaveChanges() > 0)
                                    {
                                        dto.Id      = insEntity.Id;
                                        dto.Message = "SUCCESS";
                                    }
                                    else
                                    {
                                        dto.Message = "Se ha producido un error al guardar el código de inspección";
                                    }
                                }
                            }
                        }
                    }
                    return(dto);
                }
            }
            catch (Exception ex)
            {
                return(new InspectionCodeDTO());
            }
        }
示例#3
0
        public InspectionCodeDTO Save(InspectionCodeDTO dto)
        {
            InspectionCodeDAO b = new InspectionCodeDAO();

            return(b.Save(dto));
        }
示例#4
0
        public InspectionCodeDTO SaveInspectionCode(InspectionCodeDTO dto)
        {
            InspectionCodeDAL dal = new InspectionCodeDAL();

            return(dal.Save(dto));
        }