コード例 #1
0
        // POST: odata/EstadosFormularios
        public async Task <IHttpActionResult> Post(EstadosFormulario estadosFormulario)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.EstadosFormulario.Add(estadosFormulario);
            await db.SaveChangesAsync();

            var subject = (from form in db.Formulario
                           where form.IdFormulario == estadosFormulario.IdFormulario
                           select form.CodProceso).FirstOrDefault();

            subject += " - " + (from Ep in db.EstadosProcesales
                                where Ep.IdEstados == estadosFormulario.IdEstados
                                select Ep.Nombre).FirstOrDefault();

            var correos = (from users in db.user
                           join rols in db.Rol on users.IdRol equals rols.IdRol
                           where (rols.IdRol == 2 || rols.IdRol == 1)
                           select users.email).ToList();

            CreateAppointment.Create(correos, subject, estadosFormulario.Obsevacion, estadosFormulario.FechaCumplimiento);

            return(Created(estadosFormulario));
        }
コード例 #2
0
        // DELETE: odata/EstadosFormularios(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] int key)
        {
            EstadosFormulario estadosFormulario = await db.EstadosFormulario.FindAsync(key);

            if (estadosFormulario == null)
            {
                return(NotFound());
            }

            db.EstadosFormulario.Remove(estadosFormulario);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        // PUT: odata/EstadosFormularios(5)
        public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <EstadosFormulario> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            EstadosFormulario estadosFormulario = await db.EstadosFormulario.FindAsync(key);

            if (estadosFormulario == null)
            {
                return(NotFound());
            }

            patch.Put(estadosFormulario);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EstadosFormularioExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(estadosFormulario));
        }