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

            var dispatches = Database.XMLDispatchManager.GetAll();

            //assert
            Assert.AreEqual(3, dispatches.Count());
            Assert.IsTrue(result.Succedeed);
            Assert.IsNotNull(dispatches.SingleOrDefault(x => x.Id == 2));
        }
Beispiel #2
0
        public async Task <OperationDetails> Create(GroupVisitorDTO group)
        {
            try
            {
                var model = _mapper.Map <GroupVisitorDTO, GroupVisitor>(group);
                var user  = await _database.UserManager.FindByNameAsync(group.UserInSystem);

                if (user != null)
                {
                    model.TranscriptUser = user.OperatorProfile.Transcript;
                    //system data
                    DateAndUserCreate(model, model.UserInSystem);
                    //create visitor
                    _database.GroupManager.Create(model);
                    //xml dispatch
                    await _xmlDispatcher.New(model.Visitors);

                    return(new OperationDetails(true, "Группа туристов создана", ""));
                }
                else
                {
                    return(new OperationDetails(false, "Пользователь не найден", ""));
                }
            }
            catch (Exception ex)
            {
                return(new OperationDetails(false, ex.Message, ""));
            }
        }
        public async Task <OperationDetails> Create(VisitorDTO visitor)
        {
            try
            {
                var model = _mapper.Map <VisitorDTO, Visitor>(visitor);
                await _xmlDispatcher.New(model);

                var newVisitor = _database.VisitorManager.Create(model);
                return(new OperationDetails(true, "Турист создан", ""));
            }
            catch (Exception ex)
            {
                return(new OperationDetails(false, ex.Message, ""));
            }
        }