public static void Create(AuthorViewModel target) { AuthorDao dao = new AuthorDao(); dao.Insert(target.ToEntity()); s_logger.Debug($"INSERT Author:{target}"); }
private void ImportAuthor(ILibrary libManager, AuthorViewModel add) { AuthorDao authorDao = new AuthorDao(); authorDao.Insert(add.ToEntity(), _dataOpUnit.CurrentConnection); libManager.AuthorManager.Authors.Add(add); }
public static void Update(AuthorViewModel target) { AuthorDao dao = new AuthorDao(); dao.Update(target.ToEntity()); s_logger.Debug($"UPDATE Author:{target}"); }
public async Task <IActionResult> EditAuthor(AuthorViewModel a) { if (ModelState.IsValid) { var author = a.ToEntity(); if (author.Id == 0) { await _athorsServices.CreateAuthorAsync(a.ToEntity()); } else { await _athorsServices.UpdateAuthorAsync(a.ToEntity()); } return(RedirectToAction("AllAuthors")); } return(View(a)); }
public static AuthorViewModel InsertIfNotExists(AuthorViewModel target, DataOperationUnit dataOpUnit = null) { Contract.Requires(target != null); AuthorDao dao = new AuthorDao(); if (target == null) { return(null); } else if (Exists(target.Name, dataOpUnit)) { return(FindBy(target.Name, dataOpUnit).Single().ToViewModel()); } else { dao.Insert(target.ToEntity(), dataOpUnit?.CurrentConnection); s_logger.Debug($"INSERT Author:{target}"); return(target); } }