Beispiel #1
0
        public async Task Remove_New_XMLDispatchAsync()
        {
            var result = await Service.Remove(new Visitor { Id = 1 });

            var dispatches = Database.XMLDispatchManager.GetAll();
            var dispatch   = await Database.XMLDispatchManager.GetByIdAsync(1);

            //assert
            Assert.AreEqual(1, dispatches.Count());
            Assert.IsTrue(result.Succedeed);
            Assert.IsNull(dispatch);
        }
        public async Task <OperationDetails> Delete(int id)
        {
            try
            {
                var visitor = await _database.VisitorManager.GetByIdAsync(id);

                if (visitor != null)
                {
                    await _xmlDispatcher.Remove(visitor);

                    _database.VisitorManager.Delete(id);
                    return(new OperationDetails(true, "Турист удален", ""));
                }
                else
                {
                    return(new OperationDetails(false, "Турист не найден", ""));
                }
            }
            catch (Exception ex)
            {
                return(new OperationDetails(false, ex.Message, ""));
            }
        }
Beispiel #3
0
        public async Task <OperationDetails> Delete(int id)
        {
            try
            {
                var group = await _database.GroupManager.GetByIdAsync(id);

                ICollection <Visitor> oldVisitors = new List <Visitor>(group.Visitors);
                if (group != null)
                {
                    _database.GroupManager.Delete(group.Id);
                    await _xmlDispatcher.Remove(oldVisitors);

                    return(new OperationDetails(true, "Группа туристов удалена", ""));
                }
                else
                {
                    return(new OperationDetails(false, "Группа туристов не найдена", ""));
                }
            }
            catch (Exception ex)
            {
                return(new OperationDetails(false, ex.Message, ""));
            }
        }