예제 #1
0
        public TransactionResult createP(DevolucionVo devolucion_vo, User user_log)
        {
            Devolucion devolucion = DevolucionAdapter.voToObject(devolucion_vo);

            devolucion.user = user_log;


            int id = devolucion_repository.createP(devolucion);

            if (id > 0)
            {
                var tr = TransactionResult.CREATED;
                foreach (RegistroDetalleDevVo rvo in devolucion_vo.registros)
                {
                    rvo.devolucion_id = id;
                    rvo.user_id       = devolucion.user.id;
                    tr = devolucion_repository.createRegistroDetalleDev(RegistroDetalleDevAdapter.voToObject(rvo));
                    if (tr != TransactionResult.CREATED)
                    {
                        return(tr);
                    }
                }
                return(tr);
            }
            return(TransactionResult.ERROR);
        }
예제 #2
0
 public static Devolucion voToObject(DevolucionVo vo)
 {
     return(new Devolucion
     {
         id = vo.id,
         compania = new Compania {
             id = vo.compania_id
         },
         motivo = vo.motivo,
         turno = vo.turno,
         vale = new Vale {
             id = vo.vale_id
         },
         user = new User {
             id = vo.user_id
         }
     });
 }
예제 #3
0
        public HttpResponseMessage createDevolucionP([FromBody] DevolucionVo devolucion_vo)
        {
            TransactionResult tr = devolucion_service.createP(devolucion_vo, new Models.Auth.User {
                id = int.Parse(RequestContext.Principal.Identity.Name)
            });
            IDictionary <string, string> data = new Dictionary <string, string>();

            if (tr == TransactionResult.CREATED)
            {
                data.Add("message", "Object created.");
                return(Request.CreateResponse(HttpStatusCode.Created, data));
            }
            else if (tr == TransactionResult.EXISTS)
            {
                data.Add("message", "Object already existed.");
                return(Request.CreateResponse(HttpStatusCode.Conflict, data));
            }
            else
            {
                data.Add("message", "There was an error attending your request.");
                return(Request.CreateResponse(HttpStatusCode.BadRequest, data));
            }
        }