Exemple #1
0
        public IHttpActionResult PutBook(string id, Book book)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != book.BookISBN)
            {
                return(BadRequest());
            }

            db.Entry(book).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutBicyclette(int id, Bicyclette bicyclette)
        {
            if (id != bicyclette.bicycletteId)
            {
                return(BadRequest());
            }

            db.Entry(bicyclette).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BicycletteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public IHttpActionResult PutStudent(string id, Student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != student.StudentId)
            {
                return(BadRequest());
            }

            db.Entry(student).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #4
0
        public IHttpActionResult PutAuthor(int id, Author author)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != author.AuthorID)
            {
                return(BadRequest());
            }

            db.Entry(author).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AuthorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Create([Bind(Include = "STT,MaPhieuXuat,MaHangHoa,SoLuong,NgayXuat,MaKhachHang")] chitietxuat chitietxuat)
        {
            if (ModelState.IsValid)
            {
                db.chitietxuats.Add(chitietxuat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(chitietxuat));
        }
        public ActionResult Create([Bind(Include = "STT,MaPhieuNhap,MaHangHoa,SoLuong,NgayNhap,MaNCC")] chitietnhap chitietnhap)
        {
            if (ModelState.IsValid)
            {
                db.chitietnhaps.Add(chitietnhap);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(chitietnhap));
        }
        public ActionResult Create([Bind(Include = "STT,MaHangHoa,SoNhap,SoXuat,SoTon")] NhapXuatTon nhapXuatTon)
        {
            if (ModelState.IsValid)
            {
                db.NhapXuatTons.Add(nhapXuatTon);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhapXuatTon));
        }
        public ActionResult Create([Bind(Include = "MaHangHoa,TenHangHoa,DonGia,DonViTinh,MaNCC")] Hanghoa hanghoa)
        {
            if (ModelState.IsValid)
            {
                db.Hanghoas.Add(hanghoa);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hanghoa));
        }
Exemple #9
0
        public ActionResult Create([Bind(Include = "MaNCC,TenNCC,SoDien_Thoai")] NhaCC nhaCC)
        {
            if (ModelState.IsValid)
            {
                db.NhaCCs.Add(nhaCC);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhaCC));
        }
        public ActionResult Create([Bind(Include = "MaPhieuNhap,NgayTao,MaNCC")] PhieuNhap phieuNhap)
        {
            if (ModelState.IsValid)
            {
                db.PhieuNhaps.Add(phieuNhap);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(phieuNhap));
        }
        public ActionResult Create([Bind(Include = "PhieuNhapXuat,NgayTao,MaKhachHang")] PhieuXuat phieuXuat)
        {
            if (ModelState.IsValid)
            {
                db.PhieuXuats.Add(phieuXuat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(phieuXuat));
        }
        public ActionResult Create([Bind(Include = "MaKhachHang,TenKhachHang,SoDienThoai")] KhachHang khachHang)
        {
            if (ModelState.IsValid)
            {
                db.KhachHangs.Add(khachHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(khachHang));
        }
Exemple #13
0
        public void InsertBookFile(string filename)
        {
            string line;

            using (var ctx = new modelEntities())
            {
                ctx.Database.Connection.Open();
                var file = new StreamReader(filename);

                while ((line = file.ReadLine()) != null)
                {
                    if (!line.Contains("id"))
                    {
                        var data = line.Split(';');
                        if (data.Length > 1 && !String.IsNullOrEmpty(data[19]))
                        {
                            var item = new Livre()
                            {
                                titre  = data[3].Split('[')[0],
                                auteur = data[14],
                                genre  = data[18],
                                isbn   = data[19]
                            };
                            ctx.Livre.Add(item);
                            ctx.SaveChanges();
                        }
                    }
                }
            }
        }
Exemple #14
0
        public MLivre callApiISBN(string isbn)
        {
            using (var ctx = new modelEntities())
            {
                var json  = callAPI(URL_BASE + API_KEY + BOOK_REQUEST + isbn);
                var data  = json["data"].Children();
                var livre = parseBook(data.First());

                ctx.Livre.Add(DLivre.Mapping(livre));
                ctx.SaveChanges();
                return(livre);
            }
        }
Exemple #15
0
 public int addBook(MLivre livre)
 {
     using (var ctx = new modelEntities())
     {
         ctx.Livre.Add(new Livre()
         {
             titre       = livre.Title,
             auteur      = livre.Author,
             isbn        = livre.isbn13,
             description = livre.Summary,
             genre       = livre.Genre,
             url_image   = livre.UrlImage
         });
         return(ctx.SaveChanges());
     }
     return(-1);
 }
Exemple #16
0
        public List <MLivre> callApiTitle(string title)
        {
            var result = new List <MLivre>();

            using (var ctx = new modelEntities())
            {
                title = title.Replace(" ", "+");
                var json = callAPI(URL_BASE + API_KEY + BOOKS_TITLE_REQUEST + title);
                var data = json["data"].Children().ToList();
                foreach (var item in data)
                {
                    var livre = parseBook(item);
                    if (ctx.Livre.FirstOrDefault(x => x.isbn == livre.isbn13) != null)
                    {
                        ctx.Livre.Add(DLivre.Mapping(livre));
                        ctx.SaveChanges();
                    }
                    result.Add(livre);
                }
            }
            return(result);
        }
Exemple #17
0
        public void InsertBoxFile(string filename)
        {
            string line;

            using (var ctx = new modelEntities())
            {
                ctx.Database.Connection.Open();
                var file = new StreamReader(filename);

                while ((line = file.ReadLine()) != null)
                {
                    if (!line.Contains("Code"))
                    {
                        var data = line.Split(';');
                        if (data.Length > 1)
                        {
                            var item = new Boite()
                            {
                                adresse     = data[0],
                                code_postal = data[1],
                                ville       = data[2],
                                remarque    = data[4]
                            };
                            if (!String.IsNullOrEmpty(data[3]) && data[3] != ",")
                            {
                                var coordonate = data[3].Split(',');

                                item.latitude  = decimal.Parse(coordonate[0].Replace('.', ','));
                                item.longitude = decimal.Parse(coordonate[1].Replace('.', ','));
                            }
                            ctx.Boite.Add(item);
                            ctx.SaveChanges();
                        }
                    }
                }
            };
        }