Ejemplo n.º 1
0
        public static void Create(AuthorViewModel target)
        {
            AuthorDao dao = new AuthorDao();

            dao.Insert(target.ToEntity());
            s_logger.Debug($"INSERT Author:{target}");
        }
Ejemplo n.º 2
0
        private void ImportAuthor(ILibrary libManager, AuthorViewModel add)
        {
            AuthorDao authorDao = new AuthorDao();

            authorDao.Insert(add.ToEntity(), _dataOpUnit.CurrentConnection);
            libManager.AuthorManager.Authors.Add(add);
        }
Ejemplo n.º 3
0
        public static void Update(AuthorViewModel target)
        {
            AuthorDao dao = new AuthorDao();

            dao.Update(target.ToEntity());
            s_logger.Debug($"UPDATE Author:{target}");
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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);
            }
        }