Beispiel #1
0
        public async Task <ActionResult> Edit([Bind(Include = "ID,Nombre,Descripcion,TipoID")] MedicamentosViewModel medicamento)
        {
            if (ModelState.IsValid)
            {
                var med = db.Medicamento.First(x => x.ID == medicamento.ID);
                med.Nombre      = medicamento.Nombre;
                med.Descripcion = medicamento.Descripcion;
                med.TipoID      = medicamento.TipoID;

                db.Entry(med).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(PartialView(medicamento));
        }
Beispiel #2
0
        // GET: Medicamentos/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var medicamento = await db.Medicamento.FindAsync(id);

            if (medicamento == null)
            {
                return(HttpNotFound());
            }
            var med = new MedicamentosViewModel(medicamento);

            ViewBag.MedType = new SelectList(db.Tipo_Med.ToList(), "ID", "Nombre");
            return(PartialView(med));
        }
Beispiel #3
0
        // GET: Medicamentos/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Medicamento medicamento = await db.Medicamento.FindAsync(id);

            if (medicamento == null)
            {
                return(HttpNotFound());
            }
            var med = new MedicamentosViewModel(medicamento);

            //{
            //    ID = medicameto.ID,
            //    Nombre = medicamento.Nombre,
            //    Descripcion = medicamento.Descripcion,
            //    TipoID = medicamento.TipoID
            //};
            return(PartialView(med));
        }
Beispiel #4
0
        public IActionResult Index()
        {
            MedicamentosViewModel medicamentos = new MedicamentosViewModel();

            return(View(medicamentos));
        }