public VarorModel Update(VarorModel updatedVara)
        {
            var entity = db.VarorModel.Attach(updatedVara);

            entity.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return(updatedVara);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <VarorModel> > PostVarorModel(VarorModel varorModel)
        {
            _context.VarorModel.Add(varorModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVarorModel", new { id = varorModel.Id }, varorModel));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutVarorModel(int id, VarorModel varorModel)
        {
            if (id != varorModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(varorModel).State = EntityState.Modified;

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

            return(NoContent());
        }
Ejemplo n.º 4
0
 public IActionResult OnGet(int varorId)
 {
     Varor = varorData.GetById(varorId);
     if (Varor == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     return(Page());
 }
Ejemplo n.º 5
0
        //Riktiga update
        public VarorModel Update(VarorModel updatedVara)
        {
            var vara = varor.SingleOrDefault(r => r.Id == updatedVara.Id);

            if (vara != null)
            {
                vara.Name  = updatedVara.Name;
                vara.Price = updatedVara.Price;
            }
            return(vara);
        }
 public IActionResult OnGet(int varorId)
 {
     VarorModel = varorData.GetById(varorId);
     //VarorModel = new VarorModel();
     //VarorModel.Id = varorId;
     if (VarorModel == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     return(Page());
 }
Ejemplo n.º 7
0
 public IActionResult OnGet(int?varorId)
 {
     if (varorId.HasValue)
     {
         VarorModel = varorData.GetById(varorId.Value);
     }
     else
     {
         VarorModel = new VarorModel();
     }
     if (VarorModel == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     return(Page());
 }
 public VarorModel Add(VarorModel newVara)
 {
     db.Add(newVara);
     return(newVara);
 }
Ejemplo n.º 9
0
 public VarorModel Add(VarorModel newVara)
 {
     varor.Add(newVara);
     newVara.Id = varor.Max(r => r.Id) + 1;
     return(newVara);
 }