Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("checklist_ID,checklist_description,checklist_createddate")] checklist checklist)
        {
            if (id != checklist.checklist_ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(checklist);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!checklistExists(checklist.checklist_ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(checklist));
        }
 public void Post(checklist chl)
 {
     if (ModelState.IsValid)
     {
         myEntity.checklists.Add(chl);
         myEntity.SaveChanges();
     }
 }
Example #3
0
        public async Task <IActionResult> Create([Bind("checklist_ID,checklist_description,checklist_createddate")] checklist checklist)
        {
            if (ModelState.IsValid)
            {
                _context.Add(checklist);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(checklist));
        }
 public void Put(checklist chl)
 {
     if (ModelState.IsValid)
     {
         myEntity.Entry(chl).State = EntityState.Modified;
         try
         {
             myEntity.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
        public void Delete(int id)
        {
            checklist dlt = myEntity.checklists.Find(id);

            if (dlt != null)
            {
                try
                {
                    myEntity.checklists.Remove(dlt);
                    myEntity.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        /// <summary> Method for storing an CheckList. </summary>
        /// <param name="appUser"> Incoming parameter that specifies User of CheckList. </param>
        /// <param name="list"> Specifies the CheckList. </param>
        public void StoreCheckList(EquipCheckAppUser appUser, CheckList list)
        {
            using (var db = new EquipCheckEntities())
            {
                checklist checkList = new checklist()
                {
                    checklist_name        = list.CheckListName,
                    checklist_description = list.CheckListDesc,
                    trip_name             = list.TripName,
                    trip_description      = list.TripDesc,
                    trip_date             = list.TripDate,
                    checklist_summary     = list.CheckListItemSummary,
                    user_id = appUser.UserID
                };

                db.checklists.Add(checkList);
                db.SaveChanges();
            }
        }
Example #7
0
        public string IncluirAlterarCheckList()
        {
            var auto2 = HttpContext.Current.Request.Form["autonumero"].ToString();

            if (string.IsNullOrEmpty(auto2))
            {
                auto2 = "0";
            }
            var autonumero           = Convert.ToInt32(auto2);
            var autonumeroContrato   = Convert.ToInt32(HttpContext.Current.Request.Form["autonumeroContrato"].ToString());
            var nomeContrato         = HttpContext.Current.Request.Form["nomeContrato"].ToString().Trim();
            var autonumeroSistema    = Convert.ToInt32(HttpContext.Current.Request.Form["autonumeroSistema"].ToString());
            var nomeSistema          = HttpContext.Current.Request.Form["nomeSistema"].ToString().Trim();
            var autonumeroSubsistema = Convert.ToInt32(HttpContext.Current.Request.Form["autonumeroSubsistema"].ToString());
            var nomeSubSistema       = HttpContext.Current.Request.Form["nomeSubSistema"].ToString().Trim();
            var item = HttpContext.Current.Request.Form["item"].ToString().Trim();
            var nome = HttpContext.Current.Request.Form["nome"].ToString().Trim();
            var d    = HttpContext.Current.Request.Form["d"].ToString().Trim();
            var e    = HttpContext.Current.Request.Form["e"].ToString().Trim();
            var q    = HttpContext.Current.Request.Form["q"].ToString().Trim();
            var m    = HttpContext.Current.Request.Form["m"].ToString().Trim();
            var b    = HttpContext.Current.Request.Form["b"].ToString().Trim();
            var t    = HttpContext.Current.Request.Form["t"].ToString().Trim();
            var s    = HttpContext.Current.Request.Form["s"].ToString().Trim();
            var a    = HttpContext.Current.Request.Form["a"].ToString().Trim();


            if (string.IsNullOrEmpty(d))
            {
                d = "N";
            }
            if (string.IsNullOrEmpty(e))
            {
                e = "N";
            }
            if (string.IsNullOrEmpty(q))
            {
                q = "N";
            }
            if (string.IsNullOrEmpty(m))
            {
                m = "N";
            }
            if (string.IsNullOrEmpty(b))
            {
                b = "N";
            }
            if (string.IsNullOrEmpty(t))
            {
                t = "N";
            }
            if (string.IsNullOrEmpty(s))
            {
                s = "N";
            }
            if (string.IsNullOrEmpty(a))
            {
                a = "N";
            }

            using (var dc = new manutEntities())
            {
                if (autonumero == 0)
                {
                    var k = new checklist
                    {
                        autonumeroContrato   = autonumeroContrato,
                        nomeContrato         = nomeContrato,
                        autonumeroSistema    = autonumeroSistema,
                        nomeSistema          = nomeSistema,
                        autonumeroSubsistema = autonumeroSubsistema,
                        nomeSubSistema       = nomeSubSistema,
                        item      = item,
                        nome      = nome,
                        d         = d,
                        e         = e,
                        q         = q,
                        m         = m,
                        b         = b,
                        t         = t,
                        s         = s,
                        a         = a,
                        cancelado = "N"
                    };

                    dc.checklist.Add(k);
                    dc.SaveChanges();
                    var auto = Convert.ToInt32(k.autonumero);

                    return(auto.ToString("#######0"));
                }
                else
                {
                    var linha = dc.checklist.Find(autonumero); // sempre irĂ¡ procurar pela chave primaria
                    if (linha != null && linha.cancelado != "S")
                    {
                        linha.nome = nome;
                        linha.item = item;
                        linha.d    = d;
                        linha.q    = q;
                        linha.m    = m;
                        linha.b    = b;
                        linha.t    = t;
                        linha.s    = s;
                        linha.a    = a;
                        dc.checklist.AddOrUpdate(linha);
                        dc.SaveChanges();

                        return("0");
                    }
                }
            }
            return("0");
        }
        public checklist Get(int id)
        {
            checklist chl = myEntity.checklists.Find(id);

            return(chl);
        }
        public async Task <IActionResult> PutNote([FromRoute] int id, [FromBody] Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _context.Note.Include(x => x.labellist).Include(x => x.check).ForEachAsync(x =>
            {
                if (x.Id == note.Id)
                {
                    x.NoteTitle   = note.NoteTitle;
                    x.NoteContent = note.NoteContent;
                    foreach (Labels y in note.labellist)
                    {
                        Labels a = x.labellist.Find(z => z.LabelId == y.LabelId);
                        if (a != null)
                        {
                            a.name = y.name;
                        }
                        else
                        {
                            Labels lab = new Labels()
                            {
                                name = y.name
                            };
                            x.labellist.Add(lab);
                        }
                    }

                    foreach (checklist obj in note.check)
                    {
                        checklist c = x.check.Find(z => z.checklistId == obj.checklistId);
                        if (c != null)
                        {
                            c.listcontent = obj.listcontent;
                        }
                        else
                        {
                            checklist a = new checklist {
                                listcontent = obj.listcontent
                            };
                            x.check.Add(a);
                        }
                    }
                }
            });

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }


            return(Ok(note));
        }