/// <summary>
        /// Udførelse af kommandoen.
        /// </summary>
        /// <param name="command">Command til opdatering af en given konto.</param>
        /// <returns>Opdateret konto.</returns>
        public KontoView Execute(KontoModifyCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            Regnskab regnskab;

            try
            {
                var getBrevhoved = new Func <int, Brevhoved>(nummer => _fællesRepository.BrevhovedGetByNummer(nummer));
                regnskab = _finansstyringRepository.RegnskabGetAll(getBrevhoved)
                           .Single(m => m.Nummer == command.Regnskabsnummer);
            }
            catch (InvalidOperationException ex)
            {
                throw new DataAccessSystemException(
                          Resource.GetExceptionMessage(ExceptionMessage.CantFindUniqueRecordId, typeof(Regnskab),
                                                       command.Regnskabsnummer), ex);
            }
            Kontogruppe kontogruppe;

            try
            {
                kontogruppe = _finansstyringRepository.KontogruppeGetAll().Single(m => m.Nummer == command.Kontogruppe);
            }
            catch (InvalidOperationException ex)
            {
                throw new DataAccessSystemException(
                          Resource.GetExceptionMessage(ExceptionMessage.CantFindUniqueRecordId, typeof(Kontogruppe),
                                                       command.Kontogruppe), ex);
            }

            Konto konto;

            try
            {
                konto = regnskab.Konti.OfType <Konto>().Single(m => m.Kontonummer.CompareTo(command.Kontonummer) == 0);
            }
            catch (InvalidOperationException ex)
            {
                throw new DataAccessSystemException(
                          Resource.GetExceptionMessage(ExceptionMessage.CantFindUniqueRecordId, typeof(Konto),
                                                       command.Kontonummer), ex);
            }
            konto.SætKontonavn(command.Kontonavn);
            konto.SætBeskrivelse(command.Beskrivelse);
            konto.SætNote(command.Note);
            konto.SætKontogruppe(kontogruppe);

            var opdateretKonto = _finansstyringRepository.KontoModify(regnskab, konto.Kontonummer, konto.Kontonavn,
                                                                      konto.Beskrivelse, konto.Note, konto.Kontogruppe);

            return(_objectMapper.Map <Konto, KontoView>(opdateretKonto));
        }
示例#2
0
        /// <summary>
        /// Udfører forespørgelse.
        /// </summary>
        /// <param name="query">Forespørgelse efter alle adressegrupper.</param>
        /// <returns>Alle adressegrupper.</returns>
        public IEnumerable <AdressegruppeView> Query(AdressegruppeGetAllQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            var adressegrupper = _adresseRepository.AdressegruppeGetAll();

            return(_objectMapper.Map <IEnumerable <Adressegruppe>, IEnumerable <AdressegruppeView> >(adressegrupper));
        }
        public void SaveExpertise(TrlAppExpertiseDTO model)
        {
            var trl = _dataService.GetEntity <TrlApplication>(p => p.Id == model.Id).SingleOrDefault();

            if (trl == null)
            {
                return;
            }

            var orgUnitId = trl.OrgUnitId;

            _objectMapper.Map(model, trl);
            trl.ExpertiseResult      = model.ExpertiseResultEnum;
            trl.PerformerOfExpertise = model.PerformerOfExpertiseId;
            trl.OrgUnitId            = orgUnitId;

            _dataService.SaveChanges();
            _limsExchangeService.UpdateExpertiseTRL(model); // сделал, но нет экспертизы в заяве ,
        }
示例#4
0
        public ActionResult Trades_Read([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult result = new DataSourceResult();

            result.Data = _objectMapper.Map <List <TradeDto> >(_tradeRepository.GetAll().Where(request.Filters).Where(x => x.TradingAccount.Active).OrderBy(request.Sorts[0]).Take(20).ToList());
            //result.Total = _tradeRepository.GetAll().Where(request.Filters).Where(x => x.TradingAccount.Active).Count();
            result.Total = 20;

            return(new GuerillaLogisticsApiJsonResult(result));
        }
示例#5
0
        /// <summary>
        /// Udfører forespørgelse.
        /// </summary>
        /// <param name="query">Forespørgelse efter alle postnumre.</param>
        /// <returns>Alle postnumre.</returns>
        public IEnumerable <PostnummerView> Query(PostnummerGetAllQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            var postnumre = _adresseRepository.PostnummerGetAll();

            return(_objectMapper.Map <IEnumerable <Postnummer>, IEnumerable <PostnummerView> >(postnumre));
        }
示例#6
0
        public DeviceOutputDto RegisterDevice(string token, DeviceInputDto device)
        {
            Device modelDevice = _objectMapper.Map <Device>(device);

            BindUser(modelDevice, token);

            if (!Exists(modelDevice))
            {
                _devicesRepository.Insert(modelDevice);
            }
            else
            {
                throw new InvalidRequestException();
            }

            CurrentUnitOfWork.SaveChanges();

            return(_objectMapper.Map <DeviceOutputDto>(modelDevice));
        }
示例#7
0
        public TestCompanyDto CreateCompany(CompanyInput companyInput)
        {
            var redisdb = this.redisManager.redisDb("10.12.2.61");

            if (companyInput != null)
            {
                var aaa = _objectMapper.Map <TestCompanyDto>(companyInput);
                var sss = _objectMapper.Map <TestCompany>(aaa);
                this.companyrepository.Insert(sss);
                redisdb.StringSet("test2", aaa.ToJsonString());
                //var aaa=companyInput.Obje
                //this.companyrepository.Insert()
                return(aaa);
            }
            else
            {
                return(null);
            }
        }
示例#8
0
        public static async Task <GridResult <R> > GetGridResult <T, Y, R>(this IQueryable <T> qFullQuery, IQueryable <Y> qTotalQuery, GridParam param, IObjectMapper mapper) where T : class
            where R : class
        {
            var list = await qFullQuery.ApplySearchAndFilter(param).TakePage(param).ToListAsync();

            var lstResult = mapper.Map <List <R> >(list);
            var total     = await qTotalQuery.ApplySearchAndFilter(param).CountAsync();

            return(new GridResult <R>(lstResult, total));
        }
示例#9
0
        private void AssertConvertMap <TSource, TTarget>(TSource input, TTarget output, IObjectMapper mapper)
        {
            var foo = new GenericFoo <TSource>()
            {
                Prop = input
            };
            var bar = mapper.Map <GenericBar <TTarget> >(foo);

            Assert.AreEqual(output, bar.Prop);
        }
        public void Test()
        {
            var from = new ObjectFrom
            {
                Property1 = "Property1",
                Property2 = "Property2"
            };

            var actual = objectMapper.Map <ObjectTo>(from);
        }
示例#11
0
        /// <summary>
        /// Udfører forespørgelse.
        /// </summary>
        /// <param name="query">Forespørgelse efter alle grupper for budgetkonti.</param>
        /// <returns>Alle grupper for budgetkonti.</returns>
        public IEnumerable <BudgetkontogruppeView> Query(BudgetkontogruppeGetAllQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            var budgetkontogrupper = _finansstyringRepository.BudgetkontogrupperGetAll();

            return(_objectMapper.Map <IEnumerable <Budgetkontogruppe>, IEnumerable <BudgetkontogruppeView> >(budgetkontogrupper));
        }
示例#12
0
        public virtual async Task HandleEventAsync(EntityUpdatedEto <PaymentEto> eventData)
        {
            var payment = await _paymentRepository.FindAsync(eventData.Entity.Id);

            if (payment == null)
            {
                payment = _objectMapper.Map <PaymentEto, Payment>(eventData.Entity);

                payment.SetPaymentItems(
                    _objectMapper.Map <List <PaymentItemEto>, List <PaymentItem> >(eventData.Entity.PaymentItems));

                await _paymentRepository.InsertAsync(payment, true);
            }
            else
            {
                _objectMapper.Map(eventData.Entity, payment);

                foreach (var item in eventData.Entity.PaymentItems)
                {
                    var find = payment.PaymentItems.FirstOrDefault(i => i.Id == item.Id);

                    if (find == null)
                    {
                        payment.PaymentItems.Add(_objectMapper.Map <PaymentItemEto, PaymentItem>(item));
                    }
                    else
                    {
                        _objectMapper.Map(item, find);
                    }

                    var etoPaymentItemIds = eventData.Entity.PaymentItems.Select(i => i.Id).ToList();

                    payment.PaymentItems.RemoveAll(i => !etoPaymentItemIds.Contains(i.Id));
                }
            }

            if (Guid.TryParse(eventData.Entity.GetProperty <string>("StoreId"), out var storeId))
            {
                payment.SetStoreId(storeId);
            }

            await _paymentRepository.UpdateAsync(payment, true);
        }
示例#13
0
        /// <summary>
        /// Udfører forespørgelse.
        /// </summary>
        /// <param name="query">Forespørgelse efter alle brevhoveder.</param>
        /// <returns>Alle brevhoveder.</returns>
        public IEnumerable <BrevhovedView> Query(BrevhovedGetAllQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            var brevhoveder = _fællesRepository.BrevhovedGetAll();

            return(_objectMapper.Map <IEnumerable <Brevhoved>, IEnumerable <BrevhovedView> >(brevhoveder));
        }
示例#14
0
        /// <summary>
        /// Udførelse af kommandoen.
        /// </summary>
        /// <param name="command">Command til tilføjelse af et firma.</param>
        /// <returns>Oprettet firma.</returns>
        public FirmaView Execute(FirmaAddCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            Adressegruppe adressegruppe;

            try
            {
                adressegruppe = _adresseRepository.AdressegruppeGetAll().Single(m => m.Nummer == command.Adressegruppe);
            }
            catch (InvalidOperationException ex)
            {
                throw new DataAccessSystemException(
                          Resource.GetExceptionMessage(ExceptionMessage.CantFindUniqueRecordId, typeof(Adressegruppe),
                                                       command.Adressegruppe), ex);
            }
            Betalingsbetingelse betalingsbetingelse = null;

            if (command.Betalingsbetingelse != 0)
            {
                try
                {
                    betalingsbetingelse = _adresseRepository.BetalingsbetingelserGetAll()
                                          .Single(m => m.Nummer == command.Betalingsbetingelse);
                }
                catch (InvalidOperationException ex)
                {
                    throw new DataAccessSystemException(
                              Resource.GetExceptionMessage(ExceptionMessage.CantFindUniqueRecordId,
                                                           typeof(Betalingsbetingelse), command.Betalingsbetingelse), ex);
                }
            }

            var firma = new Firma(0, command.Navn, adressegruppe);

            firma.SætAdresseoplysninger(command.Adresse1, command.Adresse2, command.PostnummerBy);
            firma.SætTelefon(command.Telefon1, command.Telefon2, command.Telefax);
            firma.SætBekendtskab(command.Bekendtskab);
            firma.SætMailadresse(command.Mailadresse);
            firma.SætWebadresse(command.Webadresse);
            firma.SætBetalingsbetingelse(betalingsbetingelse);
            firma.SætUdlånsfrist(command.Udlånsfrist);
            firma.SætFilofaxAdresselabel(command.FilofaxAdresselabel);

            var oprettetFirma = _adresseRepository.FirmaAdd(firma.Navn, firma.Adresse1, firma.Adresse2, firma.PostnrBy,
                                                            firma.Telefon1, firma.Telefon2, firma.Telefax,
                                                            firma.Adressegruppe, firma.Bekendtskab, firma.Mailadresse,
                                                            firma.Webadresse, firma.Betalingsbetingelse,
                                                            firma.Udlånsfrist, firma.FilofaxAdresselabel);

            return(_objectMapper.Map <Firma, FirmaView>(oprettetFirma));
        }
示例#15
0
        public async Task <Dictionary <string, string> > SaveNewOrg(ImlOrganizationExtFullDTO orgDto)
        {
            var errorList = new Dictionary <string, string>();

            if (orgDto.Id != Guid.Empty)
            {
                errorList.Add("", "Неможливо змінити інформацію про існуючу організацію");
                return(errorList);
            }

            bool isSameEntity;

            {
                var isFopEntity = false;
                var isOrgEntity = false;

                if (!string.IsNullOrWhiteSpace(orgDto.EDRPOU))
                {
                    var sameOrg = DataService.GetEntity <OrganizationExt>(ext =>
                                                                          ext.EDRPOU != null &&
                                                                          orgDto.EDRPOU.Equals(ext.EDRPOU, StringComparison.InvariantCultureIgnoreCase));
                    isOrgEntity = sameOrg.Any();
                }

                if (!string.IsNullOrWhiteSpace(orgDto.INN))
                {
                    var sameFop = DataService.GetEntity <OrganizationExt>(ext =>
                                                                          ext.INN != null &&
                                                                          orgDto.INN.Equals(ext.INN, StringComparison.InvariantCultureIgnoreCase));
                    isFopEntity = sameFop.Any();
                }

                isSameEntity = isFopEntity || isOrgEntity;
            }

            if (isSameEntity)
            {
                errorList.Add("", "Організація з таким ІНН\\ЄДРПОУ вже існує");
                return(errorList);
            }

            var orgGuid = DataService.Add <OrganizationExt>(orgDto, false);

            orgDto.Id = orgGuid;
            var orgInfo = _objectMapper.Map <OrganizationInfo>(orgDto);

            orgInfo.OrganizationId = orgGuid;
            orgInfo.Type           = "IML";
            orgInfo.IsActualInfo   = true;
            DataService.Add(orgInfo, false);

            await DataService.SaveChangesAsync();

            return(errorList);
        }
示例#16
0
        public async Task <IActionResult> Save(AdminInputModel input)
        {
            var liveShowDetails = await _liveShowDetails.LoadAsync() ?? new LiveShowDetails();

            if (!ModelState.IsValid)
            {
                // Model validation error, just return and let the error render
                var viewModel = new AdminViewModel();
                UpdateAdminViewModel(viewModel, liveShowDetails);

                return(View(nameof(Index), viewModel));
            }

            if (!string.IsNullOrEmpty(input.LiveShowEmbedUrl))
            {
                // Convert live show url to HTTPS if need be
                if (input.LiveShowEmbedUrl.StartsWith("http://"))
                {
                    input.LiveShowEmbedUrl = "https://" + input.LiveShowEmbedUrl.Substring("http://".Length);
                }

                // Convert watch URL to embed URL
                if (input.LiveShowEmbedUrl.StartsWith("https://www.youtube.com/watch?v=", StringComparison.OrdinalIgnoreCase))
                {
                    var queryIndex   = input.LiveShowEmbedUrl.LastIndexOf("?v=", StringComparison.OrdinalIgnoreCase);
                    var showIdLength = input.LiveShowEmbedUrl.IndexOf('&', queryIndex) - 3 - queryIndex;
                    var showId       = showIdLength > 0 ? input.LiveShowEmbedUrl.Substring(queryIndex + 3, showIdLength) : input.LiveShowEmbedUrl.Substring(queryIndex + 3);
                    input.LiveShowEmbedUrl = $"https://www.youtube.com/embed/{showId}";
                }
            }

            TrackShowEvent(input, liveShowDetails);

            _mapper.Map(input, liveShowDetails);
            liveShowDetails.NextShowDateUtc = input.NextShowDatePst?.ConvertFromPtcToUtc();

            await _liveShowDetails.SaveAsync(liveShowDetails);

            TempData[nameof(AdminViewModel.SuccessMessage)] = "Live show details saved successfully!";

            return(RedirectToAction(nameof(Index)));
        }
示例#17
0
        public ActionResult Index()
        {
            var logentries = _service.GetLog();

            return(View(new LogModel
            {
                Entries = _mapper.Map <IEnumerable <LogEntry>, IEnumerable <LogEntryModel> >(logentries),
                Severities = new string[] { "INFO" },
                AppModules = new string[] { "Main Web App" },
            }));
        }
示例#18
0
 Task <List <Api.Task> > ITaskRepository.GetMyTasks(string CurrentUserName)
 {
     if (!string.IsNullOrEmpty(CurrentUserName))
     {
         // Call API and Get json object
         dynamic json     = "";
         var     jsonoObj = JObject.Parse(json);
         return(ObjectMapper.Map <JObject, Api.Task>(jsonoObj));
     }
     return(null);
 }
        public void Should_Map_Objects_With_AutoMap_Attributes()
        {
            var dto = _objectMapper.Map <MyEntity, MyEntityDto>(
                new MyEntity
            {
                Number = 42
            }
                );

            dto.As <MyEntityDto>().Number.ShouldBe(42);
        }
示例#20
0
 public Task <List <BookStore.EServices.Task> > GetMyTasks(string CurrentUserName)
 {
     if (!string.IsNullOrEmpty(CurrentUserName))
     {
         // Call API and Get json object
         dynamic json     = "";
         var     jsonoObj = JObject.Parse(json);
         return(ObjectMapper.Map <JObject, Api.Task>(jsonoObj));
     }
     return(null);
 }
示例#21
0
        public IList <MessageDto> GetMyMessages()
        {
            if (_abpSession.UserId == null)
            {
                //throw new UserFriendlyException("Please log in before attemping to get messages.");
                return(new List <MessageDto>());
            }

            var list = _MessageRepository.GetAllList(p => p.ReceiveUserId == _abpSession.UserId);

            return(_objectMapper.Map <List <MessageDto> >(list));
        }
示例#22
0
        public IActionResult Detail([FromRoute] string id)
        {
            var output = _issueAppService.GetIssue(new GetIssueInput {
                Id = id
            });

            var viewModel = _objectMapper.Map <IssueDetailViewModel>(output);

            viewModel.CurrentUserId = _sessionService.UserId;

            return(View(viewModel));
        }
        public virtual async Task <List <ChatMessage> > GetGroupMessageAsync(
            Guid?tenantId,
            long groupId,
            string filter      = "",
            string sorting     = nameof(ChatMessage.MessageId),
            bool reverse       = true,
            MessageType?type   = null,
            int skipCount      = 0,
            int maxResultCount = 10,
            CancellationToken cancellationToken = default)
        {
            using (_currentTenant.Change(tenantId))
            {
                var groupMessages = await _messageRepository
                                    .GetGroupMessagesAsync(groupId, filter, sorting, reverse, type, skipCount, maxResultCount, cancellationToken);

                var chatMessages = _objectMapper.Map <List <GroupMessage>, List <ChatMessage> >(groupMessages);

                return(chatMessages);
            }
        }
        public async Task <List <ProductCategoryDto> > GetPublicListAsync(MallRequestDto input)
        {
            input.Sorting = input.Sorting.IsNullOrEmptyOrWhiteSpace() ? "sort desc" : input.Sorting;
            var list = await DbSet
                       .Include(x => x.AppProductCategories)
                       .WhereIf(input.ShopId.HasValue, x => x.ShopId == input.ShopId)
                       .WhereIf(!input.AppName.IsNullOrEmptyOrWhiteSpace(), x => x.IsGlobal || x.AppProductCategories.Any(b => b.AppName == input.AppName))
                       .OrderBy(input.Sorting)
                       .ToListAsync();

            return(_mapper.Map <List <ProductCategory>, List <ProductCategoryDto> >(list));
        }
示例#25
0
文件: Team.cs 项目: aidbal/Mindfights
        public async Task <TeamDto> GetTeam(long teamId)
        {
            var currentTeam = await _teamRepository
                              .GetAllIncluding(team => team.Players)
                              .FirstOrDefaultAsync(x => x.Id == teamId);

            if (currentTeam == null)
            {
                throw new UserFriendlyException("Komanda su tokiu id neegizstuoja1");
            }

            var teamDto = new TeamDto();

            _objectMapper.Map(currentTeam, teamDto);
            var leader = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == currentTeam.LeaderId);

            teamDto.LeaderName   = leader.Name;
            teamDto.PlayersCount = currentTeam.Players.Count;
            teamDto.GamePoints   = currentTeam.Players.Sum(player => player.Points);
            return(teamDto);
        }
        /// <summary>
        /// Udfører forespørgelse.
        /// </summary>
        /// <param name="query">Forespørgelse efter alle adresser til en adresseliste.</param>
        /// <returns>Alle adresser til en adresseliste.</returns>
        public IEnumerable <AdresselisteView> Query(AdresselisteGetAllQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            var getBrevhoved = new Func <int, Brevhoved>(nummer => _fællesRepository.BrevhovedGetByNummer(nummer));
            var regnskaber   = _finansstyringRepository.RegnskabGetAll(getBrevhoved);
            var adresser     = _adresseRepository.AdresseGetAll(adresse => MergeInformations(adresse, regnskaber));

            return(_objectMapper.Map <IEnumerable <AdresseBase>, IEnumerable <AdresselisteView> >(adresser));
        }
示例#27
0
        /// <summary>
        /// Udfører forespørgelse.
        /// </summary>
        /// <param name="query">Forespørgelse efter alle betalingsbetingelser.</param>
        /// <returns>Alle betalingsbetingelser.</returns>
        public IEnumerable <BetalingsbetingelseView> Query(BetalingsbetingelseGetAllQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            var betalingsbetingelser = _adresseRepository.BetalingsbetingelserGetAll();

            return
                (_objectMapper.Map <IEnumerable <Betalingsbetingelse>, IEnumerable <BetalingsbetingelseView> >(
                     betalingsbetingelser));
        }
示例#28
0
        public OrderDto GetOrderDtoTest()
        {
            var order = new Order
            {
                OrderName   = "测试",
                PhoneNumber = "11111111111"
            };

            var orderDto = _objectMapper.Map <OrderDto>(order);

            return(orderDto);
        }
        public List <PlayHistoryDto> GetTableHistories(int tableId)
        {
            var playHistories = _dbContext.PlayHistoreis
                                .Include(x => x.PlayHistoryDetails)
                                .ThenInclude(phd => phd.Players)
                                .Where(x => x.TableId == tableId && x.IsPlaying == true)
                                .OrderBy(x => x.CreationTime)
                                .ToList();
            var result = _objectMapper.Map <List <PlayHistoryDto> >(playHistories);

            return(result);
        }
示例#30
0
        /// <summary>
        /// Get the current status of the block chain.
        /// </summary>
        /// <returns></returns>
        public async Task <ChainStatusDto> GetChainStatusAsync()
        {
            var basicContractZero = _smartContractAddressService.GetZeroSmartContractAddress();

            var chain = await _blockchainService.GetChainAsync();

            var result = _objectMapper.Map <Kernel.Chain, ChainStatusDto>(chain);

            result.GenesisContractAddress = basicContractZero?.ToBase58();

            return(result);
        }