Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Book book = MappingWeb.ConvertToWebEntity(_bookRepo.Read(id));

            _bookRepo.Delete(MappingWeb.ConvertToBusinessEntity(book));
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Owner owner = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(id));

            _ownerRepo.Delete(MappingWeb.ConvertToBusinessEntity(owner));
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Author author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(id));

            _authorRepo.Delete(MappingWeb.ConvertToBusinessEntity(author));
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,UniqueIdNumber,Address,Gender,PhoneNumber,Email,isDeleted")] Owner owner)
 {
     if (ModelState.IsValid)
     {
         _ownerRepo.Update(MappingWeb.ConvertToBusinessEntity(owner)); // = EntityState.Modified;
         return(RedirectToAction("Index"));
     }
     return(View(owner));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Gender,Birthdate,isDeleted")] Author author)
 {
     if (ModelState.IsValid)
     {
         _authorRepo.Update(MappingWeb.ConvertToBusinessEntity(author)); // = EntityState.Modified;
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
        public ActionResult Create([Bind(Include = "Id,Name,UniqueIdNumber,Address,Gender,PhoneNumber,Email,isDeleted")] Owner owner)
        {
            if (ModelState.IsValid)
            {
                owner.isDeleted = false;
                _ownerRepo.Create(MappingWeb.ConvertToBusinessEntity(owner));
                return(RedirectToAction("Index"));
            }

            return(View(owner));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Gender,Birthdate")] Author author)
        {
            if (ModelState.IsValid)
            {
                author.isDeleted = false;
                _authorRepo.Create(MappingWeb.ConvertToBusinessEntity(author));
                //_authorRepo.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(author));
        }
        // GET: Owners
        public ActionResult Index()
        {
            var owners = _ownerRepo.ReadAll();

            var list = new List <Owner>();

            foreach (var owner in owners)
            {
                list.Add(MappingWeb.ConvertToWebEntity(owner));
            }

            return(View(list));
        }
        // GET: Authors
        public ActionResult Index()
        {
            var authors = _authorRepo.ReadAll();

            var list = new List <Author>();

            foreach (var author in authors)
            {
                list.Add(MappingWeb.ConvertToWebEntity(author));
            }

            return(View(list));
        }
        // GET: Owners/Edit/5
        public ActionResult Edit(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Owner owner = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(id));

            if (owner == null)
            {
                return(HttpNotFound());
            }
            return(View(owner));
        }
        // GET: Authors/Details/5
        public ActionResult Details(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Author author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(id));

            if (author == null)
            {
                return(HttpNotFound());
            }
            return(View(author));
        }
Пример #12
0
        public ActionResult Hire(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Book book = MappingWeb.ConvertToWebEntity(_bookRepo.Read(id));

            if (book == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.AuthorId = new SelectList(_authorRepo.ReadAll(), "Id", "Name", book.AuthorId);
            ViewBag.OwnerId = new SelectList(_ownerRepo.ReadAll(), "Id", "Name", book.OwnerId);
            return(View(book));
        }
Пример #13
0
 public ActionResult Edit([Bind(Include = "Id,Name,ISBN,countPages,datePublished,AuthorId")] Book book)
 {
     if (ModelState.IsValid)
     {
         book.Author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(book.AuthorId));
         var ownerIdFromRepo = MappingWeb.ConvertToWebEntity(_bookRepo.Read(book.Id)).OwnerId;
         book.isDeleted = false;
         book.OwnerId   = ownerIdFromRepo;
         book.Owner     = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(ownerIdFromRepo));
         _bookRepo.Update(MappingWeb.ConvertToBusinessEntity(book));
         return(RedirectToAction("Index"));
     }
     ViewBag.AuthorId = new SelectList(_authorRepo.ReadAll(), "Id", "Name", book.AuthorId);
     ViewBag.OwnerId  = new SelectList(_ownerRepo.ReadAll(), "Id", "Name", book.OwnerId);
     return(View(book));
 }
Пример #14
0
        // GET: Books/Details/5
        public ActionResult Details(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Book book = MappingWeb.ConvertToWebEntity(_bookRepo.Read(id));

            book.Author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(book.AuthorId));
            book.Owner  = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(book.OwnerId));

            if (book == null)
            {
                return(HttpNotFound());
            }
            return(View(book));
        }
Пример #15
0
        // GET: Books
        public ActionResult Index()
        {
            var books = _bookRepo.ReadAll();

            var list = new List <Book>();

            foreach (var book in books)
            {
                //book.Author = _authorRepo.Read(book.AuthorId);
                //book.Owner = _ownerRepo.Read(book.OwnerId);
                var current = MappingWeb.ConvertToWebEntity(book);
                current.Author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(book.AuthorId));
                current.Owner  = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(book.OwnerId));

                list.Add(current);
            }

            return(View(list));
        }