Ejemplo n.º 1
0
        public IHttpActionResult PutServiceAuthor(int id, ServiceAuthor serviceAuthor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != serviceAuthor.serviceAuthorId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public int AddAuthor(ServiceAuthor author)
        {
            int id = unit.Authors.Create(author.ToDalAuthor());

            unit.Save();
            return(id);
        }
Ejemplo n.º 3
0
        public ServiceFullAuthor GetFullAuthorInfo(ServiceAuthor author)
        {
            ServiceFullAuthor fullAuthor = new ServiceFullAuthor();

            fullAuthor.AuthorData  = author;
            fullAuthor.AuthorBooks = unit.Authors.GetBooks(author.ToDalAuthor()).Select(e => e.ToServiceBook());
            return(fullAuthor);
        }
Ejemplo n.º 4
0
 public static AuthorShortModel ToAuthorShortModel(this ServiceAuthor author)
 {
     return(new AuthorShortModel()
     {
         ID = author.ID,
         Name = author.Name,
         PhotoPath = author.Photo
     });
 }
Ejemplo n.º 5
0
        public JsonResult AddAuthor(string name)
        {
            var author = new ServiceAuthor();

            author.serviceAuthorName = name;
            context.author.Add(author);
            context.SaveChanges();
            return(Json(new { result = "success" }));
        }
Ejemplo n.º 6
0
 public static AuthorCreateModel ToAuthorCreateModel(this ServiceAuthor author)
 {
     return(new AuthorCreateModel()
     {
         Name = author.Name,
         BirthDate = author.BirthDate,
         DeathDate = author.DeathDate,
         Biography = author.Biography
     });
 }
Ejemplo n.º 7
0
        public IHttpActionResult GetServiceAuthor(int id)
        {
            ServiceAuthor serviceAuthor = db.author.Find(id);

            if (serviceAuthor == null)
            {
                return(NotFound());
            }

            return(Ok(serviceAuthor));
        }
Ejemplo n.º 8
0
 public static AuthorEditModel ToAuthorEditModel(this ServiceAuthor author)
 {
     return(new AuthorEditModel()
     {
         ID = author.ID,
         Name = author.Name,
         BirthDate = author.BirthDate,
         DeathDate = author.DeathDate,
         Biography = author.Biography,
         PhotoPath = author.Photo
     });
 }
Ejemplo n.º 9
0
        public IHttpActionResult PostServiceAuthor(ServiceAuthor serviceAuthor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.author.Add(serviceAuthor);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = serviceAuthor.serviceAuthorId }, serviceAuthor));
        }
Ejemplo n.º 10
0
 public static DalAuthor ToDalAuthor(this ServiceAuthor author)
 {
     return(new DalAuthor()
     {
         ID = author.ID,
         Name = author.Name,
         BirthDate = author.BirthDate,
         DeathDate = author.DeathDate,
         Biography = author.Biography,
         Photo = author.Photo
     });
 }
Ejemplo n.º 11
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         try
         {
             Models = ServiceAuthor.GetListAllModel();
         }
         catch (Exception e)
         {
         }
     }
 }
Ejemplo n.º 12
0
        public IHttpActionResult DeleteServiceAuthor(int id)
        {
            ServiceAuthor serviceAuthor = db.author.Find(id);

            if (serviceAuthor == null)
            {
                return(NotFound());
            }

            db.author.Remove(serviceAuthor);
            db.SaveChanges();

            return(Ok(serviceAuthor));
        }
Ejemplo n.º 13
0
        //Makes a new contact with preloaded information


        /// <returns></returns>
        public async Task <ActionResult> ContactDisplay()

        {
            var db = new UserDbContext();

            // ViewBag.mycontacts = db.Contacts.ToList();

            // string query = "SELECT * FROM Contact WHERE Username = @p0";
            // Contacts department = await db.Contacts.SqlQuery(query, Session["name"]).SingleOrDefaultAsync();

            ServiceAuthor service = new ServiceAuthor();
            await db.SaveChangesAsync();

            return(View(service.ReturnAuthor()));
        }
Ejemplo n.º 14
0
 public void RemoveAuthorBook(ServiceAuthor author, ServiceBook book)
 {
     unit.Books.DeleteAuthor(book.ToDalBook(), author.ToDalAuthor());
     unit.Save();
 }
Ejemplo n.º 15
0
 public void RemoveAuthor(ServiceAuthor author)
 {
     unit.Authors.Delete(author.ToDalAuthor());
     unit.Save();
 }
Ejemplo n.º 16
0
 public void AddAuthorBook(ServiceAuthor author, ServiceBook book)
 {
     unit.Books.AddAuthor(book.ToDalBook(), author.ToDalAuthor());
     unit.Save();
 }
Ejemplo n.º 17
0
 public void UpdateAuthor(ServiceAuthor author)
 {
     unit.Authors.Update(author.ToDalAuthor());
     unit.Save();
 }
Ejemplo n.º 18
0
 public AuthorController(DBMusicContext context, ServiceAuthor service)
 {
     _service = service;
 }