public ActionResult Edit(int id, RfIdCard rfIdCard) { try { RfIdCard updatedrfIdCard = db.RfIdCard.Where(x => x.IDCard == id).FirstOrDefault(); updatedrfIdCard.SerialNumber = rfIdCard.SerialNumber; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(RfIdCard rfIdCard) { try { db.RfIdCard.Add(new RfIdCard { SerialNumber = rfIdCard.SerialNumber }); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, RfIdUser rfIdUser) { try { User userToUpdate = db.User.Where(x => x.IDUser == id).FirstOrDefault(); userToUpdate.Name = rfIdUser.User.Name; userToUpdate.Surname = rfIdUser.User.Surname; userToUpdate.OIB = rfIdUser.User.OIB; userToUpdate.Address = rfIdUser.User.Address; RfIdCard rfIdCard = db.RfIdCard.Where(x => x.SerialNumber == rfIdUser.RfIdCard.SerialNumber).FirstOrDefault(); RfIdUser rfIdUserToUpdate = db.RfIdUser.Where(x => x.IDRfIdUser == rfIdUser.IDRfIdUser).FirstOrDefault(); rfIdUserToUpdate.CardId = rfIdCard.IDCard; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }