コード例 #1
0
        public void AddEditOutgoing(OutgoingDTO outgoingdto)
        {
            var outgoing = outgoingdto.Map();

            if (outgoing.Id > 0)
            {
                var current = _context.Set <Outgoing>().FirstOrDefault(x => x.Id == outgoing.Id);
                if (current != null)
                {
                    current.OutgoingLocalization = outgoing.OutgoingLocalization;
                    current.OutgoingTime         = outgoing.OutgoingTime;
                    current.ParticipantsCount    = outgoing.ParticipantsCount;
                    current.PhotoUrl             = outgoing.PhotoUrl;
                    current.Price        = outgoing.Price;
                    current.TagList      = outgoing.TagList;
                    current.AgeGroupMax  = outgoing.AgeGroupMax;
                    current.AgeGroupMin  = outgoing.AgeGroupMin;
                    current.Title        = outgoing.Title;
                    current.FirstName    = outgoing.FirstName;
                    current.Name         = outgoing.Name;
                    current.OutgoingDate = outgoing.OutgoingDate;
                    current.CreateDate   = outgoing.CreateDate;
                }
            }
            else
            {
                _context.Set <Outgoing>().Add(outgoing);
            }
            _context.SaveChanges();
        }
コード例 #2
0
        public static Outgoing Map(this OutgoingDTO source)
        {
            var target = new Outgoing();

            target.CreateDate                     = DateTime.Now;
            target.Id                             = source.Id;
            target.Name                           = source.Name;
            target.AgeGroupMax                    = source.AgeGroupMax;
            target.AgeGroupMin                    = source.AgeGroupMin;
            target.FirstName                      = source.FirstName;
            target.OutgoingDate                   = source.OutgoingDate;
            target.Title                          = source.Title;
            target.ParticipantsCount              = source.ParticipantsCount;
            target.OutgoingTime                   = source.OutgoingTime;
            target.PhotoUrl                       = source.PhotoUrl;
            target.Price                          = source.Price;
            target.MinPeople                      = source.MinPeople;
            target.MaxPeople                      = source.MaxPeople;
            target.OutgoingLocalization           = new Localization();
            target.OutgoingLocalization.Latitude  = source.OutgoingLocalization.Latitude;
            target.OutgoingLocalization.longitude = source.OutgoingLocalization.longitude;

            return(target);
        }
コード例 #3
0
 void IOutgoingCommandService.AddEditOutgoing(OutgoingDTO dto)
 {
     _outgoingCommandRepository.AddEditOutgoing(dto);
 }
コード例 #4
0
        public List <OutgoingDTO> GetAllIdAndCoords()
        {
            List <Outgoing> tempList = new List <Outgoing>();

            tempList.Add(new Outgoing()
            {
                CreateDate           = DateTime.Now,
                MaxPeople            = 5,
                MinPeople            = 2,
                OutgoingLocalization = new Localization()
                {
                    Latitude  = 52.2296760,
                    longitude = 21.0122290
                },
                Id = 1
            });
            tempList.Add(new Outgoing()
            {
                CreateDate           = DateTime.Now,
                MaxPeople            = 3,
                MinPeople            = 1,
                OutgoingLocalization = new Localization()
                {
                    Latitude  = 50.6829932,
                    longitude = 17.8717630
                },
                Id = 2
            });
            tempList.Add(new Outgoing()
            {
                CreateDate           = DateTime.Now,
                MaxPeople            = 3,
                MinPeople            = 1,
                OutgoingLocalization = new Localization()
                {
                    Latitude  = 50.6817152,
                    longitude = 17.8773205
                },
                Id = 3
            });
            tempList.Add(new Outgoing()
            {
                CreateDate           = DateTime.Now,
                MaxPeople            = 5,
                MinPeople            = 1,
                OutgoingLocalization = new Localization()
                {
                    Latitude  = 50.6813617,
                    longitude = 17.8838865
                },
                Id = 4
            });
            tempList.Add(new Outgoing()
            {
                CreateDate           = DateTime.Now,
                MaxPeople            = 2,
                MinPeople            = 1,
                OutgoingLocalization = new Localization()
                {
                    Latitude  = 50.6766028,
                    longitude = 17.9055159
                },
                Id = 5
            });
            var entity = tempList.Select(x => x);
            var result = new List <OutgoingDTO>();

            foreach (var outgoing in entity)
            {
                var item = new OutgoingDTO();
                item.OutgoingLocalization           = new LocalizationDTO();
                item.OutgoingLocalization.Latitude  = outgoing.OutgoingLocalization.Latitude;
                item.OutgoingLocalization.longitude = outgoing.OutgoingLocalization.longitude;
                item.Id = outgoing.Id;
                result.Add(item);
            }
            return(result);
        }