public async Task <HttpResponseMessage> SaveRequest(Request request)
        {
            return(await ValidateAndHandleOperationExecutionAsync(async() =>
            {
                int?status = 0;
                //Validation val = null;
                TimeContribution tc = null;
                var ent = await _entitleDomainService.GetEntitleById(UserIdentity);

                var req = new Request();
                if (request.RequestId == Guid.Empty)
                {
                    //  req.Date = DateTime.Now;
                    req.Folio = "PEN" + ent.NoISSSTE.PadLeft(10, '0') + DateTime.Now.ToString("yyMMddhhmmss");
                }
                else
                {
                    req = await _requestDomainService.GetRequestByRequestId(request.RequestId);
                }


                //  req.Description = request.Description;
                if (request.EntitleId != null)
                {
                    req.EntitleId = request.EntitleId;
                }
                else
                {
                    req.EntitleId = ent.CURP;
                }


                //   req.IsAssigned = request.IsAssigned;
                request.Folio = req.Folio;

                req.IsComplete = status == 100 ? true : false;
                var result = await _requestDomainService.SaveRequest(req);
                var res = await _requestDomainService.SaveStatusRequestByEntitle(req, true, status, ent.CURP);
                if (!(bool)req.IsComplete) //0 en BD
                {
                    await _requestDomainService.SaveStatusRequestByEntitle(req, true, (int)StatusEnum.EnesperadeAgendarCiraDer, ent.CURP);
                }
                //if (val != null); MFP 10-01-2017
                //req.Validation = val;
                return Request.CreateResponse(HttpStatusCode.OK, req);
            }));
        }
Example #2
0
 public async Task <HttpResponseMessage> SaveAppointment(Appoinment appoinment)
 {
     return(await ValidateAndHandleOperationExecutionAsync(async() =>
     {
         var result = await _calendarDomainService.SaveAppointment(appoinment);
         var request = await _requestDomainService.GetRequestByRequestId(appoinment.RequestId);
         var entitle = await _entitleDomainService.GetEntitleByCurp(request.EntitleId.ToString());
         var res =
             await
             _requestDomainService.SaveStatusRequestByEntitle(request, true, 202,
                                                              entitle.CURP); // 340 => Cita agendada
         return Request.CreateResponse(HttpStatusCode.OK, result);
     }));
 }