Exemple #1
0
        public async Task <OperationDetails> Update(GroupVisitorDTO group)
        {
            try
            {
                var model = await _database.GroupManager.GetByIdAsync(group.Id);

                ICollection <Visitor> oldVisitors = new List <Visitor>(model.Visitors);

                if (model != null)
                {
                    DateAndUserUpdate(group, model, group.UserEdit);
                    var mapper   = new MapperConfiguration(cfg => cfg.AddProfile(new ProfileGroupDtoToDao(_database, model))).CreateMapper();
                    var modelNew = mapper.Map <GroupVisitorDTO, GroupVisitor>(group);

                    _database.GroupManager.Update(modelNew);
                    await _xmlDispatcher.Edit(oldVisitors, modelNew.Visitors);

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

            throw new NotImplementedException();
        }
        public async Task <OperationDetails> Update(VisitorDTO visitor)
        {
            try
            {
                var model = await _database.VisitorManager.GetByIdAsync(visitor.Id);

                if (model != null)
                {
                    var mapper = new MapperConfiguration(cfg => cfg.AddProfile(new FromDALToBLLProfileWithModelVisitor(_database, model))).CreateMapper();
                    var m      = mapper.Map <VisitorDTO, Visitor>(visitor);

                    await _xmlDispatcher.Edit(model);

                    _database.VisitorManager.Update(m);

                    return(new OperationDetails(true, "Турист изменен", ""));
                }
                else
                {
                    return(new OperationDetails(false, "Турист не найден", ""));
                }
            }
            catch (Exception ex)
            {
                return(new OperationDetails(false, ex.Message, ""));
            }
        }
Exemple #3
0
        public async Task Edit_New_XMLDispatchAsync()
        {
            var result = await Service.Edit(new Visitor { Id = 1 });

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

            //assert
            Assert.AreEqual(2, dispatches.Count());
            Assert.IsTrue(result.Succedeed);
            Assert.IsNotNull(dispatch);
            Assert.AreEqual(Status.New, dispatch.Status);
            Assert.AreEqual(Operation.Add, dispatch.Operation);
        }