Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 3
0
 public ActionResult Kino(Kino kinoModel)
 {
     using (KinoContext context = new KinoContext())
     {
         context.KinoComments.Add(kinoModel);
         context.SaveChanges();
     }
     return(View("Kino", new Kino()));
 }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
 public void Save()
 {
     _context.SaveChanges();
 }