public virtual TModel Insert(TInsert request) { var entity = _mapper.Map <TDatabase>(request); _context.Add(entity); _context.SaveChanges(); return(_mapper.Map <TModel>(entity)); }
public Model.Korisnici Delete(int id) { var entity = _context.Korisnici.Find(id); _context.Remove(entity); _context.SaveChanges(); return(_mapper.Map <Model.Korisnici>(entity)); }
public ActionResult Kino(Kino kinoModel) { using (KinoContext context = new KinoContext()) { context.KinoComments.Add(kinoModel); context.SaveChanges(); } return(View("Kino", new Kino())); }
public List <Model.Sjedista> Insert(SjedistaInsertRequest request) { var entity = _mapper.Map <List <Database.Sjedista> >(request.sjedista); foreach (var item in entity) { _context.Add(item); _context.SaveChanges(); } return(_mapper.Map <List <Model.Sjedista> >(request.sjedista)); }
public Ulaznice Insert(UlazniceInsertRequest request, string baseUrl) { var entity = _mapper.Map <Database.Ulaznice>(request); _context.Add(entity); _context.SaveChanges(); QRCodeGenerator qr = new QRCodeGenerator(); QRCodeData data = qr.CreateQrCode(baseUrl + "api/Ulaznice/Provjera/" + entity.UlaznicaID, QRCodeGenerator.ECCLevel.Q); QRCode code = new QRCode(data); Bitmap qrCodeImage = code.GetGraphic(10); var bitmapBytes = BitmapToBytes(qrCodeImage); entity.BarCodeIMG = bitmapBytes; _context.SaveChanges(); return(_mapper.Map <Model.Ulaznice>(entity)); }
private void ButtonFechar_Click(object sender, RoutedEventArgs e) { using (KinoContext db = new KinoContext()) { db.Subscriptions.RemoveRange(db.Subscriptions); db.SaveChanges(); foreach (var x in allfilms.ToList()) { var subs = x.Subscribers; foreach (User s in subs.ToList()) { db.Subscriptions.Add(new Subscription { UserId = s.Id, FilmId = x.Id }); db.SaveChanges(); } } } Application.Current.Shutdown(); }
public void Save() { _context.SaveChanges(); }