Exemple #1
0
        public async Task DeleteJournal(string itemID)
        {
            int id = 0;

            if (int.TryParse(itemID, out id) == false)
            {
                await GeneralLibraryLogic.SaveToLogFile("Id is not valid");

                throw new BLLJournalException("Id is not valid");
            }
            try
            {
                Journal j1 = await _journalRep.GetJournal(id);

                await _journalRep.DeleteJournal(j1);
            }
            catch (Exception e)
            {
                if (e is JournalException ||
                    e is DALException)
                {
                    await GeneralLibraryLogic.SaveToLogFile(e.ToString());

                    throw new BLLJournalException("Cannot delete a journal atm try again later or call a manager");
                }
                else
                {
                    await GeneralLibraryLogic.SaveToLogFile(e.ToString());

                    throw new LibraryException("Unknown error inform a manager!");
                }
            }
        }
        public ActionResult Delete(JournalViewModel journal)
        {
            var selectedJournal = Mapper.Map <JournalViewModel, Journal>(journal);

            var opStatus = _journalRepository.DeleteJournal(selectedJournal);

            if (!opStatus.Status)
            {
                throw new System.Web.Http.HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            return(RedirectToAction("Index"));
        }