예제 #1
0
        public virtual bool Delete(T item)
        {
            bool deleteResult  = false;
            var  publisherById = _curDapperRep.GetById(item.Id);

            if (publisherById != null)
            {
                var mapper       = new MapperConfiguration(cfg => cfg.CreateMap <T, K>()).CreateMapper();
                var itemToDelete = mapper.Map <T, K>(item);
                try
                {
                    deleteResult = _curDapperRep.Delete(itemToDelete);
                    return(deleteResult);
                }
                catch (Exception)
                {
                    Console.WriteLine("Current item has external links, cant delete");
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }