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)); }
public int AddAuthor(ServiceAuthor author) { int id = unit.Authors.Create(author.ToDalAuthor()); unit.Save(); return(id); }
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); }
public static AuthorShortModel ToAuthorShortModel(this ServiceAuthor author) { return(new AuthorShortModel() { ID = author.ID, Name = author.Name, PhotoPath = author.Photo }); }
public JsonResult AddAuthor(string name) { var author = new ServiceAuthor(); author.serviceAuthorName = name; context.author.Add(author); context.SaveChanges(); return(Json(new { result = "success" })); }
public static AuthorCreateModel ToAuthorCreateModel(this ServiceAuthor author) { return(new AuthorCreateModel() { Name = author.Name, BirthDate = author.BirthDate, DeathDate = author.DeathDate, Biography = author.Biography }); }
public IHttpActionResult GetServiceAuthor(int id) { ServiceAuthor serviceAuthor = db.author.Find(id); if (serviceAuthor == null) { return(NotFound()); } return(Ok(serviceAuthor)); }
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 }); }
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)); }
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 }); }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { try { Models = ServiceAuthor.GetListAllModel(); } catch (Exception e) { } } }
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)); }
//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())); }
public void RemoveAuthorBook(ServiceAuthor author, ServiceBook book) { unit.Books.DeleteAuthor(book.ToDalBook(), author.ToDalAuthor()); unit.Save(); }
public void RemoveAuthor(ServiceAuthor author) { unit.Authors.Delete(author.ToDalAuthor()); unit.Save(); }
public void AddAuthorBook(ServiceAuthor author, ServiceBook book) { unit.Books.AddAuthor(book.ToDalBook(), author.ToDalAuthor()); unit.Save(); }
public void UpdateAuthor(ServiceAuthor author) { unit.Authors.Update(author.ToDalAuthor()); unit.Save(); }
public AuthorController(DBMusicContext context, ServiceAuthor service) { _service = service; }