Exemplo n.º 1
0
        public ActionResult Delete(int id)
        {
            UserSessionObject    user         = Session.GetUser();
            DeleteLanguageResult deleteResult = LanguageService.Delete(id, user);

            return(Json(deleteResult, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public DeleteLanguageResult Delete(int?languageId, UserSessionObject user)
        {
            var result = new DeleteLanguageResult();

            if (languageId.HasValue)
            {
                if (!CheckReferencingBooks(languageId.Value))
                {
                    LanguageData domainModel = LanguageRepository.GetDataById(languageId.Value);
                    if (domainModel != null)
                    {
                        LanguageRepository.DeleteById(languageId.Value, user.UserId);
                        result = new DeleteLanguageResult(languageId.Value, domainModel.NameLanguage);
                    }
                }
                else
                {
                    result.Message = "This language can't be deleted. There are books connected to this language.";
                }
            }

            return(result);
        }