Exemplo n.º 1
0
 public JsonResult Get()
 {
     using (var ctx = new libraryContext())
     {
         return(Json(new FineRepository(ctx).GetFines()));
         //, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
     }
 }
Exemplo n.º 2
0
        public IActionResult Update([FromBody] Rooms entity)
        {
            var context = new libraryContext();

            context.Update(entity);
            context.SaveChanges();
            return(Ok(entity));
        }
 public void Delete(string isbn)
 {
     using (var ctx = new libraryContext())
     {
         new BooksRepository(ctx).DeleteByIsbn(isbn);
         ctx.SaveChanges();
     }
 }
 public void Post([FromBody] string name)
 {
     using (var ctx = new libraryContext())
     {
         new AuthorRepository(ctx).Add(name);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 5
0
        public IActionResult Remove(int id)
        {
            var context = new libraryContext();

            context.Rooms.Remove(context.Rooms.Find(id));
            context.SaveChanges();
            return(Ok(context.Rooms.ToList()));
        }
 public void Put(int id)
 {
     using (var ctx = new libraryContext())
     {
         new BookLoanRepository(ctx).Update(id);
         ctx.SaveChanges();
     }
 }
 public void Put(int id, [FromBody] string name)
 {
     using (var ctx = new libraryContext())
     {
         new AuthorRepository(ctx).Update(id, name);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public JsonResult update()
 {
     using (var ctx = new libraryContext()) {
         new FineRepository(ctx).updateFines();
         ctx.SaveChanges();
         return(this.Get());
     }
 }
 public JsonResult GetSearch(string search)
 {
     using (var ctx = new libraryContext())
     {
         return(Json(new BookLoanRepository(ctx).Search(search), new JsonSerializerSettings {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore
         }));
     }
 }
 public JsonResult Get(int id)
 {
     using (var ctx = new libraryContext())
     {
         return(Json(new BookLoanRepository(ctx).GetById(id).ToList(), new JsonSerializerSettings {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore
         }));
     }
 }
 public JsonResult Get()
 {
     using (var ctx = new libraryContext())
     {
         var data = new BookLoanRepository(ctx).GetBookLoans().ToList();
         return(Json(data, new JsonSerializerSettings {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore
         }));
     }
 }
Exemplo n.º 12
0
 public string Put(int id, [FromBody] string name)
 {
     using (var ctx = new libraryContext())
     {
         var result = new PublisherRepository(ctx).Update(id, name);
         if (result == string.Empty)
         {
             ctx.SaveChanges();
         }
         return(result);
     }
 }
 public string Put(int id, [FromBody] string isbn, string title, string cover, int pages, string publisher, string[] authors)
 {
     using (var ctx = new libraryContext())
     {
         var result = new BooksRepository(ctx).Update(isbn, title, cover, pages, publisher, authors);
         if (result == string.Empty)
         {
             ctx.SaveChanges();
         }
         return(result);
     }
 }
Exemplo n.º 14
0
 public JsonResult Put(int id)
 {
     using (var ctx = new libraryContext())
     {
         if (new FineRepository(ctx).PayFine(id))
         {
             ctx.SaveChanges();
             return(Json(new { message = "success" }));
         }
         else
         {
             return(Json(new { error = "failed to update the fine, Try again later." }));
         }
         //new FineRepository(ctx).PayFine(), new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
     }
 }
 public JsonResult Post([FromBody] BookLoans loan)
 {
     using (var ctx = new libraryContext())
     {
         var BkLnRepo = new BookLoanRepository(ctx);
         var result   = BkLnRepo.Add(loan);
         if (result == null)
         {
             ctx.SaveChanges();
             return(Json(new { message = "Success" }));
         }
         else
         {
             return(Json(new { error = result }));
         }
     }
 }
Exemplo n.º 16
0
        public IActionResult Add([FromBody] Rooms entity)
        {
            if (entity == null)
            {
                return(BadRequest());
            }
            var context = new libraryContext();

            context.Rooms.Add(entity);
            context.SaveChanges();
            if (entity.Id > 0)
            {
                return(Ok(entity));
            }

            return(BadRequest());
        }
Exemplo n.º 17
0
 public PositionsController(libraryContext context)
 {
     _context = context;
 }
 public BooksRepository(libraryContext ctx)
 {
     this.context = ctx; this.pubRep = new PublisherRepository(context); this.authRep = new AuthorRepository(context); this.bkAuthRep = new BookAuthorRepository(context);
 }
 public FineRepository(libraryContext ctx)
 {
     this.context = ctx;
 }
 public PublisherRepository(libraryContext ctx)
 {
     this.context = ctx;
 }
 public PublisherRepository()
 {
     this.context = new libraryContext();
 }
        public string get()
        {
            using (var ctx = new libraryContext())
            {
                var AuthorRepo    = new AuthorRepository(ctx);
                var PublisherRepo = new PublisherRepository(ctx);
                var BooksRepo     = new BooksRepository(ctx);
                try
                {
                    var authorFile = @"E:\OneDrive - The University of Texas at Dallas\Spring18\DB\Projects\project1\books.csv";
                    //var borrowerFile = "";
                    List <Model>     list       = new List <Model>();
                    var              fileStream = new FileStream(authorFile, FileMode.Open, FileAccess.Read);
                    HashSet <string> authors    = new HashSet <string>();
                    HashSet <string> publishers = new HashSet <string>();
                    using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
                    {
                        string line;
                        line = streamReader.ReadLine();
                        while ((line = streamReader.ReadLine()) != null)
                        {
                            var temp = line.Split('\t');
                            foreach (var author in temp[3].Split(','))
                            {
                                authors.Add(author);
                            }

                            publishers.Add(temp[5]);

                            int pages = Int16.Parse(temp[6]);
                            var model = new Model(temp[0], temp[2], temp[3].Split(','), temp[4], temp[5], pages);
                            list.Add(model);
                            //BooksRepo.Add(temp[0], temp[2], temp[5], Int16.Parse(temp[6]), temp[4], temp[3].Split(','));
                            //ctx.SaveChanges();
                        }
                    }
                    foreach (var author in authors)
                    {
                        AuthorRepo.Add(author);
                    }
                    foreach (var publisher in publishers)
                    {
                        PublisherRepo.Add(publisher);
                    }
                    ctx.SaveChanges();
                    var count = 0;
                    foreach (var item in list)
                    {
                        count++;
                        BooksRepo.Add(item.isbn, item.title, item.cover, item.pages, item.publisher, item.authors);
                        if (count % 5000 == 0)
                        {
                            Console.Write(ctx.SaveChanges());
                        }
                    }
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    return(e.Message);
                }
                return("Success");
            }
        }
Exemplo n.º 23
0
        public IActionResult GetAll()
        {
            var context = new libraryContext();

            return(Ok(context.Rooms.ToList()));
        }
Exemplo n.º 24
0
 public BookListData(libraryContext context)
 {
     _context = context;
 }
Exemplo n.º 25
0
        public IActionResult Get(int id)
        {
            var context = new libraryContext();

            return(Ok(context.Rooms.Find(id)));
        }
 public BorrowerRepository(libraryContext ctx)
 {
     this.context = ctx;
 }
Exemplo n.º 27
0
 public BookController(libraryContext context)
 {
     _context = context;
 }
Exemplo n.º 28
0
 public BookAuthorRepository()
 {
     this.context = new libraryContext();
 }
Exemplo n.º 29
0
 public BookAuthorRepository(libraryContext ctx)
 {
     this.context = ctx;
 }
 public BorrowerRepository()
 {
     this.context = new libraryContext();
 }