Beispiel #1
0
        /// <summary>
        /// Retrieve a SiteStaff with associated lookups
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public SiteStaffVMDC GetSiteStaff(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <SiteStaff> dataRepository
                                          , IRepository <Site> siteRepository
                                          , IRepository <Staff> staffRepository
                                          , IExceptionManager exceptionManager, IMappingService mappingService)

        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    SiteStaffDC destination = null;

                    // If code is null then just return supporting lists
                    if (!string.IsNullOrEmpty(code))
                    {
                        // Convert code to Guid
                        Guid codeGuid = Guid.Parse(code);

                        // Retrieve specific SiteStaff
                        SiteStaff dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                        // Convert to data contract for passing through service interface
                        destination = mappingService.Map <SiteStaff, SiteStaffDC>(dataEntity);
                    }

                    IEnumerable <Site>  siteList  = siteRepository.GetAll(x => new { x.SiteName });
                    IEnumerable <Staff> staffList = staffRepository.GetAll(x => new { x.StaffNumber });

                    List <SiteDC>  siteDestinationList  = mappingService.Map <List <SiteDC> >(siteList);
                    List <StaffDC> staffDestinationList = mappingService.Map <List <StaffDC> >(staffList);

                    // Create aggregate contract
                    SiteStaffVMDC returnObject = new SiteStaffVMDC();

                    returnObject.SiteStaffItem = destination;
                    returnObject.SiteList      = siteDestinationList;
                    returnObject.StaffList     = staffDestinationList;

                    return(returnObject);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
Beispiel #2
0
 public PageViewModel GetByAlias(string alias)
 {
     return(Mapper.Map <Page, PageViewModel>(_pageRepository.Single(x => x.UniqueCode == alias)));
 }
        /// <summary>
        /// Retrieve a IncidentSystemMarked with associated lookups
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public IncidentSystemMarkedVMDC GetIncidentSystemMarked(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <IncidentSystemMarked> dataRepository
                                                                , IRepository <Incident> incidentRepository
                                                                , IRepository <SystemMarked> systemMarkedRepository
                                                                , IExceptionManager exceptionManager, IMappingService mappingService)

        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    IncidentSystemMarkedDC destination = null;

                    // If code is null then just return supporting lists
                    if (!string.IsNullOrEmpty(code))
                    {
                        // Convert code to Guid
                        Guid codeGuid = Guid.Parse(code);

                        // Retrieve specific IncidentSystemMarked
                        IncidentSystemMarked dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                        // Convert to data contract for passing through service interface
                        destination = mappingService.Map <IncidentSystemMarked, IncidentSystemMarkedDC>(dataEntity);
                    }

                    IEnumerable <Incident>     incidentList     = incidentRepository.GetAll(x => new { x.IncidentID });
                    IEnumerable <SystemMarked> systemMarkedList = systemMarkedRepository.GetAll(x => new { x.Description });

                    List <IncidentDC>     incidentDestinationList     = mappingService.Map <List <IncidentDC> >(incidentList);
                    List <SystemMarkedDC> systemMarkedDestinationList = mappingService.Map <List <SystemMarkedDC> >(systemMarkedList);

                    // Create aggregate contract
                    IncidentSystemMarkedVMDC returnObject = new IncidentSystemMarkedVMDC();

                    returnObject.IncidentSystemMarkedItem = destination;
                    returnObject.IncidentList             = incidentDestinationList;
                    returnObject.SystemMarkedList         = systemMarkedDestinationList;

                    return(returnObject);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
Beispiel #4
0
 public SystemConfigViewModel GetSystemConfig(string code)
 {
     return(Mapper.Map <Setting, SystemConfigViewModel>(_systemConfigRepository.Single(x => x.UniqueCode == code)));
 }
        public Task <Client> FindClientByIdAsync(string ClientId)
        {
            var client = _dbRepository.Single <Client>(c => c.ClientId == ClientId);

            return(Task.FromResult(client));
        }
        private void InitForm()
        {
            try
            {
                lblMemberName.Text = $"<b>{MemberName}</b> (<em>NO.{Mid}</em>)";

                if (OrderID > 0)
                {
                    var o = (OrdrTicket)Order.Select(OrderID);

                    // For Vincent Song to View the MatchTickets Confirmation Page
                    if (ConfigGlobal.IsPluginAdmin(Uid) || (Uid.Equals(33067) && (int)o.Status >= 3))
                    {
                        lblMemberName.Text = $"<b>{o.MemberName}</b> (<em>NO.{o.MemberID}</em>)";
                    }
                    else
                    {
                        if (o == null || !o.MemberID.Equals(Mid) || !o.IsActive)
                        {
                            throw new Exception("此订单无效或非当前用户订单");
                        }
                    }

                    #region Bind OrderView Status Workflow

                    if (ucPortalWorkflowInfo != null)
                    {
                        ucPortalWorkflowInfo.JSONOrderStatusList = $"[ {string.Join(",", o.StatusWorkflowInfo)} ]";
                        ucPortalWorkflowInfo.CurrOrderStatus     = o.Status;
                    }

                    #endregion

                    var m = _repo.Single <Member>(o.MemberID);

                    lblOrderMobile.Text = $"<em>{o.Mobile}</em>";

                    #region Set Member Nation & Region

                    if (!string.IsNullOrEmpty(m.Nation))
                    {
                        if (m.Nation.Equals("中国"))
                        {
                            lblMemberRegion.Text = "中国 ";

                            var region = m.Region.Split('|');

                            foreach (var t in region)
                            {
                                int regionId;

                                if (int.TryParse(t, out regionId))
                                {
                                    lblMemberRegion.Text += DictionaryItem.Cache.Load(regionId).Name + " ";
                                }
                            }
                        }
                        else
                        {
                            lblMemberRegion.Text = m.Nation;
                        }
                    }
                    else
                    {
                        lblMemberRegion.Text = "无";
                    }

                    #endregion

                    lblMemberIDCardNo.Text     = m.IDCardNo;
                    lblMemberPassportNo.Text   = m.PassportNo;
                    lblMemberPassportName.Text = m.PassportName;
                    lblMemberWeChat.Text       = $"<em>{m.WeChat}</em>";
                    lblMemberEmail.Text        = $"<em>{m.Email}</em>";

                    lblOrderID.Text          = $"<em>{o.ID}</em>";
                    lblOrderCreateTime.Text  = o.CreateTime.ToString("yyyy-MM-dd HH:mm");
                    lblOrderDescription.Text = o.Description;

                    if (!string.IsNullOrEmpty(o.Remark))
                    {
                        lblOrderRemark.Text   = o.Remark.Replace("\r\n", "<br />");
                        phOrderRemark.Visible = true;
                    }
                    else
                    {
                        phOrderRemark.Visible = false;
                    }

                    // Should be Calculator in this Page
                    double price;
                    string priceInfo;

                    var oiMatchTicket = o.OIMatchTicket;

                    // Get Order MatchTicket Info

                    bool isMemberCouldPurchase;

                    if (oiMatchTicket != null && oiMatchTicket.IsActive)
                    {
                        var mt = MatchTicket.Cache.Load(oiMatchTicket.MatchGuid);

                        if (mt == null)
                        {
                            throw new Exception("无相关比赛信息,请联系管理员");
                        }

                        var mp = MemberPeriod.GetCurrentMemberPeriodByMemberID(Mid);

                        isMemberCouldPurchase = mt.CheckMemberCanPurchase(mp);

                        var p = Product.Cache.Load(mt.ProductCode);

                        if (p == null)
                        {
                            throw new Exception("无相关商品信息,请联系管理员");
                        }

                        lblMatchTicketInfo.Text =
                            $"<em>【{mt.LeagueName}】{mt.TeamName}({Arsenal_Team.Cache.Load(mt.TeamGuid).TeamEnglishName})</em>";
                        lblMatchTicketPlayTime.Text =
                            $"<em>【伦敦】{mt.PlayTimeLocal.ToString("yyyy-MM-dd HH:mm")}</em>";

                        var strRank = mt.ProductInfo.Trim();
                        if (lblMatchTicketRank != null && !string.IsNullOrEmpty(strRank))
                        {
                            lblMatchTicketRank.Text = $"<em>{strRank.Substring(strRank.Length - 7, 7)}</em>";
                        }

                        if (mt.AllowMemberClass.HasValue && mt.AllowMemberClass.Value == 2)
                        {
                            lblMatchTicketAllowMemberClass.Text = "<em>只限高级会员 (Premier) </em>";
                        }
                        else if (mt.AllowMemberClass.HasValue && mt.AllowMemberClass == 1)
                        {
                            lblMatchTicketAllowMemberClass.Text = "<em>普通会员 (Core) 以上</em>";
                        }
                        else
                        {
                            lblMatchTicketAllowMemberClass.Text = "无";
                        }

                        ucPortalMatchInfo.MatchGuid = mt.ID;

                        lblOrderItem_TravelDate.Text = oiMatchTicket.TravelDate.ToString("yyyy年MM月dd日");


                        // Set Order Price

                        price     = oiMatchTicket.TotalPrice;
                        priceInfo = string.Format("<合计> {2}:{0} × {1}", oiMatchTicket.UnitPrice.ToString("f2"),
                                                  oiMatchTicket.Quantity,
                                                  Product.Cache.Load(oiMatchTicket.ProductGuid).DisplayName);

                        tbOrderPrice.Text  = price.ToString(CultureInfo.CurrentCulture);
                        lblOrderPrice.Text = $"{priceInfo} = <em>{price.ToString("f2")}</em>元";

                        if (o.Status.Equals(OrderStatusType.Draft))
                        {
                            btnSubmit.Visible = true;
                            btnModify.Visible = true;
                            btnCancel.Visible = true;

                            if (!isMemberCouldPurchase)
                            {
                                lblOrderRemark.Text =
                                    $@"<em style='line-height: 1.8'>由于球票供应有限,所有主场球票预订均只向(Core/Premier)会员开放。<br />
                                        <a href='ServerMembershipCheck.ashx?OrderID={OrderID}' target='_blank' style='background: #fff48d'>
                                        【点击这里】请在续费或升级会员资格后,才能提交订单。</a></em>";
                                phOrderRemark.Visible = true;

                                btnSubmit.Visible = false;
                            }
                        }
                        else if (o.Status.Equals(OrderStatusType.Submitted))
                        {
                            btnSubmit.Visible = false;
                            btnModify.Visible = false;
                            btnCancel.Visible = true;

                            ucPortalProductQrCode.QrCodeUrl      = p.QrCodeUrl;
                            ucPortalProductQrCode.QrCodeProvider = "淘宝";
                        }
                        else
                        {
                            btnSubmit.Visible = false;
                            btnModify.Visible = false;
                            btnCancel.Visible = false;
                        }
                    }
                    else
                    {
                        throw new Exception("此订单未填写订票信息");
                    }
                }
                else
                {
                    throw new Exception("此订单不存在");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "failed",
                                                       $"alert('{ex.Message}');window.location.href = 'iArsenalOrder.aspx'", true);
            }
        }
        public async Task HandleEventAsync(OrderSubscriptionPayedEventData eventData)
        {
            PlanPrice planPrice = _planPriceRepository.GetByOrder(eventData.Entity);

            IEnumerable <Order> paymentPendingOrders = _orderRepository.GetPendingPayments(planPrice.Plan, eventData.Entity.UserId);

            foreach (Order order in paymentPendingOrders)
            {
                Order orderToUpdate = null;
                SubscriptionCycleOrder subscriptionCycleOrder = null;
                SubscriptionCycle      subscriptionCycle      = null;
                Subscription           subscription           = null;


                if (order.Id == eventData.Entity.Id)
                {
                    orderToUpdate = _orderRepository.Get(eventData.Entity.Id);

                    subscriptionCycleOrder = _subscriptionCycleOrderRepository.GetAll().Single(x => x.OrderId == orderToUpdate.Id);
                    subscriptionCycle      = _subscriptionCycleRepository.Get(subscriptionCycleOrder.SubscriptionCycleId);
                    subscription           = _subscriptionRepository.Get(subscriptionCycle.SubscriptionId);

                    _orderDomainService.PayOrder(orderToUpdate);
                    _subscriptionDomainService.ActiveSubscription(subscription);
                    _subscriptionCycleDomainService.ActiveSubscriptionCycle(subscriptionCycle, DateTime.Now, planPrice.Plan.Duration);

                    Invoice invoice = _invoiceRepository.Single(x => x.OrderId == order.Id);
                    _invoiceDomainService.PayInvoice(invoice);
                    _invoiceRepository.Update(invoice);

                    Notification notification = _notificationDomainService.CreateNotification(orderToUpdate);
                    _notificationDomainService.SetOrderPayed(notification);
                    _noticationRepository.Insert(notification);

                    NotificationDto notificationDto = _mapper.Map <NotificationDto>(notification);

                    HttpResponseMessage httpResponse = await _httpClient.PostAsJsonAsync(_clientOptions.NotificactionUrl, notificationDto);

                    if (httpResponse.IsSuccessStatusCode)
                    {
                        _noticationRepository.Delete(notification);
                    }
                    else
                    {
                        _notificationDomainService.AddAttempt(notification);

                        _noticationRepository.Update(notification);
                    }
                }
                else
                {
                    orderToUpdate = _orderRepository.Get(order.Id);

                    subscriptionCycleOrder = _subscriptionCycleOrderRepository.GetAll().Single(x => x.OrderId == orderToUpdate.Id);
                    subscriptionCycle      = _subscriptionCycleRepository.Get(subscriptionCycleOrder.SubscriptionCycleId);
                    subscription           = _subscriptionRepository.Get(subscriptionCycle.SubscriptionId);

                    _subscriptionDomainService.CancelSubscription(subscription);
                    _subscriptionCycleDomainService.CancelSubscriptionCycle(subscriptionCycle);
                    _orderDomainService.CancelOrder(orderToUpdate);

                    Invoice invoice = _invoiceRepository.GetAllIncluding(x => x.InvocePaymentProviders).Single(x => x.OrderId == order.Id);
                    _invoiceDomainService.CancelInvoice(invoice);
                    _invoiceRepository.Update(invoice);

                    PaymentProvider.PaymentProviderValue paymentProviderValue = order.Currency.Code == Currency.CurrencyValue.USD ? PaymentProvider.PaymentProviderValue.Paypal : PaymentProvider.PaymentProviderValue.Mobbex;
                    InvoicePaymentProvider invoicePaymentProvider             = invoice.InvocePaymentProviders.Single(x => x.PaymentProvider.Provider == paymentProviderValue);

                    switch (order.Currency.Code)
                    {
                    case Currency.CurrencyValue.ARS:
                        await _mobbexService.CancelInvoice(invoicePaymentProvider);

                        break;

                    case Currency.CurrencyValue.USD:
                        await _paypalService.CancelInvoice(invoicePaymentProvider);

                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }

                _subscriptionRepository.Update(subscription);
                _subscriptionCycleRepository.Update(subscriptionCycle);
                _orderRepository.Update(orderToUpdate);
            }
        }
Beispiel #8
0
 public async Task <FeedCollection> Get(Guid id)
 {
     return(await _collections.Single(id));
 }
        private void InitForm()
        {
            try
            {
                lblMemberName.Text    = $"<b>{MemberName}</b> (<em>NO.{Mid}</em>)";
                lblMemberACNInfo.Text = $"<b>{Username}</b> (<em>ID.{Uid}</em>)";

                if (MatchGuid.Equals(Guid.Empty))
                {
                    Response.Redirect("iArsenalOrder_MatchList.aspx");
                    Response.Clear();
                }

                var mt = MatchTicket.Cache.Load(MatchGuid);

                if (mt == null)
                {
                    throw new Exception("无相关比赛信息,请联系管理员");
                }

                if (OrderID <= 0 && mt.Deadline < DateTime.Now && mt.WaitingDeadline < DateTime.Now)
                {
                    throw new Exception("此球票预定已过截止时间或补票时间,无法预订,请联系管理员");
                }

                //if (!mt.IsMemberCouldPurchase(this.CurrentMemberPeriod))
                //{
                //    ClientScript.RegisterClientScriptBlock(typeof(string), "failed",
                //        string.Format("alert('由于球票数量紧张,所有阿森纳主场球票预订,均只向收费会员开放,请在跳转页面后续费或升级会员资格');window.location.href = 'iArsenalMemberPeriod.aspx'"), true);
                //}

                var p = Product.Cache.Load(mt.ProductCode);

                if (p == null)
                {
                    throw new Exception("无相关商品信息,请联系管理员");
                }

                lblMatchTicketInfo.Text =
                    $"<em>【{mt.LeagueName}】{mt.TeamName}({Arsenal_Team.Cache.Load(mt.TeamGuid).TeamEnglishName})</em>";
                lblMatchTicketPlayTime.Text = $"<em>【伦敦】{mt.PlayTimeLocal.ToString("yyyy-MM-dd HH:mm")}</em>";

                var strRank = mt.ProductInfo.Trim();
                if (lblMatchTicketRank != null)
                {
                    lblMatchTicketRank.Text = !string.IsNullOrEmpty(strRank) ? $"<em>{strRank.Substring(strRank.Length - 7, 7)} - {p.PriceInfo}</em>" : string.Empty;
                }

                if (mt.AllowMemberClass.HasValue && mt.AllowMemberClass.Value == 2)
                {
                    lblAllowMemberClass.Text = "<em>只限高级会员(Premier)</em>";
                }
                else if (mt.AllowMemberClass.HasValue && mt.AllowMemberClass == 1)
                {
                    lblAllowMemberClass.Text = "<em>普通会员(Core)以上</em>";
                }
                else
                {
                    lblAllowMemberClass.Text = "无";
                }

                if (OrderID > 0)
                {
                    var o = (OrdrTicket)Order.Select(OrderID);

                    if (o == null || !o.IsActive)
                    {
                        throw new Exception("此订单无效");
                    }

                    if (ConfigGlobal.IsPluginAdmin(Uid) || o.MemberID.Equals(Mid))
                    {
                        lblMemberName.Text = $"<b>{o.MemberName}</b> (<em>NO.{o.MemberID}</em>)";

                        var m = _repo.Single <Member>(o.MemberID);

                        if (m == null || !m.IsActive)
                        {
                            throw new Exception("无此会员信息");
                        }
                        lblMemberACNInfo.Text = $"<b>{m.AcnName}</b> (<em>ID.{m.AcnID}</em>)";

                        #region Set Member Nation & Region

                        if (!string.IsNullOrEmpty(m.Nation))
                        {
                            if (m.Nation.Equals("中国"))
                            {
                                ddlNation.SelectedValue = m.Nation;

                                var region = m.Region.Split('|');
                                if (region.Length > 1)
                                {
                                    tbRegion1.Text = region[0];
                                    tbRegion2.Text = region[1];
                                }
                                else
                                {
                                    tbRegion1.Text = region[0];
                                    tbRegion2.Text = string.Empty;
                                }
                            }
                            else
                            {
                                ddlNation.SelectedValue = "其他";
                                tbNation.Text           = m.Nation.Equals("其他") ? string.Empty : m.Nation;
                            }
                        }
                        else
                        {
                            ddlNation.SelectedValue = string.Empty;
                        }

                        #endregion

                        tbIDCardNo.Text     = m.IDCardNo;
                        tbPassportNo.Text   = m.PassportNo;
                        tbPassportName.Text = m.PassportName;
                        tbMobile.Text       = m.Mobile;
                        tbWeChat.Text       = m.WeChat;
                        tbEmail.Text        = m.Email;

                        tbOrderDescription.Text = o.Description;
                    }
                    else
                    {
                        throw new Exception("此订单非当前用户订单");
                    }

                    var oi = o.OIMatchTicket;

                    if (oi != null)
                    {
                        //tbQuantity.Text = oi.Quantity.ToString();
                        tbTravelDate.Text = oi.TravelDate.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        throw new Exception("此订单未填写订票信息");
                    }
                }
                else
                {
                    //Fill Member draft information into textbox
                    var m = _repo.Single <Member>(Mid);

                    #region Set Member Nation & Region

                    if (!string.IsNullOrEmpty(m.Nation))
                    {
                        if (m.Nation.Equals("中国"))
                        {
                            ddlNation.SelectedValue = m.Nation;

                            var region = m.Region.Split('|');
                            if (region.Length > 1)
                            {
                                tbRegion1.Text = region[0];
                                tbRegion2.Text = region[1];
                            }
                            else
                            {
                                tbRegion1.Text = region[0];
                                tbRegion2.Text = string.Empty;
                            }
                        }
                        else
                        {
                            ddlNation.SelectedValue = "其他";
                            tbNation.Text           = m.Nation.Equals("其他") ? string.Empty : m.Nation;
                        }
                    }
                    else
                    {
                        ddlNation.SelectedValue = string.Empty;
                    }

                    #endregion

                    tbIDCardNo.Text     = m.IDCardNo;
                    tbPassportNo.Text   = m.PassportNo;
                    tbPassportName.Text = m.PassportName;
                    tbMobile.Text       = m.Mobile;
                    tbWeChat.Text       = m.WeChat;
                    tbEmail.Text        = m.Email;

                    tbTravelDate.Text = mt.PlayTime.AddDays(-2).ToString("yyyy-MM-dd");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "failed",
                                                       $"alert('{ex.Message}');window.location.href = 'iArsenalOrder_MatchList.aspx'", true);
            }
        }
Beispiel #10
0
        private void InitForm()
        {
            if (VideoGuid != Guid.Empty)
            {
                var v = _repo.Single <Video>(VideoGuid);

                tbVideoGuid.Text = VideoGuid.ToString();
                tbFileName.Text  = v.FileName;

                #region Set Video ArsenalMatchGuid

                if (v.ArsenalMatchGuid.HasValue)
                {
                    var m = Match.Cache.Load(v.ArsenalMatchGuid.Value);

                    if (m != null)
                    {
                        if (m.LeagueGuid.HasValue)
                        {
                            ddlLeague.SelectedValue = m.LeagueGuid.Value.ToString();
                            BindMatchData(m.LeagueGuid.Value);
                            ddlMatch.SelectedValue = v.ArsenalMatchGuid.Value.ToString();
                        }
                    }
                }
                else
                {
                    ddlLeague.SelectedValue = string.Empty;
                    ddlMatch.Items.Clear();
                }

                #endregion

                if (v.GoalPlayerGuid.HasValue)
                {
                    ddlGoalPlayer.SelectedValue = v.GoalPlayerGuid.Value.ToString();
                }
                else
                {
                    ddlGoalPlayer.SelectedValue = string.Empty;
                }

                if (v.AssistPlayerGuid.HasValue)
                {
                    ddlAssistPlayer.SelectedValue = v.AssistPlayerGuid.Value.ToString();
                }
                else
                {
                    ddlAssistPlayer.SelectedValue = string.Empty;
                }

                tbGoalRank.Text            = v.GoalRank;
                tbTeamworkRank.Text        = v.TeamworkRank;
                tbGoalYear.Text            = v.GoalYear;
                tbOpponent.Text            = v.Opponent;
                ddlVideoType.SelectedValue = v.VideoType.ToString();
                tbVideoLength.Text         = v.VideoLength.ToString();
                tbVideoWidth.Text          = v.VideoWidth.ToString();
                tbVideoHeight.Text         = v.VideoHeight.ToString();
            }
            else
            {
                tbVideoGuid.Text = Guid.NewGuid().ToString();
            }
        }
        public Task <PersistedGrant> GetAsync(string key)
        {
            var result = _dbRepository.Single <PersistedGrant>(i => i.Key == key);

            return(Task.FromResult(result));
        }
Beispiel #12
0
        public async Task <string> GetBotScript(Guid botId)
        {
            var botScript = await _scriptRepository.Single(x => x.Id == botId);

            return(botScript?.Script);
        }
Beispiel #13
0
        public HtmlDataOperRetDto UpdateFormulaById(int input, CreateFormulaDto formula)
        {
            var oldItem = _eleFormulaRep.Single(x => x.Id == input);

            if (oldItem == null)
            {
                return
                    (new HtmlDataOperRetDto()
                {
                    Code = -1,
                    Message = "该公式不存在!"
                });
            }

            int rowCount = this._eleFormulaRep.GetAll().Where(x => x.eleId == oldItem.eleId && x.name == formula.name).Count();

            if (rowCount > 1)
            {
                return(new HtmlDataOperRetDto()
                {
                    Code = -1,
                    Message = "该名称已存在!"
                });
            }

            string formulaStr = formula.formulaExp;

            // 处理特殊字符,转小写
            formulaStr = formulaStr.Replace(')', ')');
            formulaStr = formulaStr.Replace('(', '(');
            formulaStr = formulaStr.ToLower();
            formulaStr = formulaStr.Replace(" ", "");

            // 解决mv/c这种匹配问题
            string expFromat = "([tmvc]\\d *){ 2,}";
            var    expMatch  = Regex.Matches(expFromat, formulaStr);

            if (expMatch.Count > 0)
            {
                return(new HtmlDataOperRetDto()
                {
                    Code = -1,
                    Message = "该公式不合法!"
                });
            }

            // 简单的匹配
            string mPattern = "m\\d*";
            string vPattern = "v\\d*";
            string cPattern = "c\\d*";
            string tPattern = "t\\d*";

            // 参数替换成常数99,判断是否是正常的四则表达式
            string tempFormula = Regex.Replace(formulaStr, mPattern, "99");

            tempFormula = Regex.Replace(tempFormula, vPattern, "99");
            tempFormula = Regex.Replace(tempFormula, cPattern, "99");
            tempFormula = Regex.Replace(tempFormula, tPattern, "99");

            if (CheckExpressionValid(tempFormula))
            {
                // 提取参数
                List <string> pramList = new List <string>();
                var           mMatches = Regex.Matches(formulaStr, mPattern);
                foreach (var item in mMatches)
                {
                    pramList.Add(item.ToString());
                }
                var cMatches = Regex.Matches(formulaStr, cPattern);
                foreach (var item in cMatches)
                {
                    pramList.Add(item.ToString());
                }
                var vMatch = Regex.Matches(formulaStr, vPattern);
                foreach (var item in vMatch)
                {
                    pramList.Add(item.ToString());
                }
                var tMatch = Regex.Matches(formulaStr, tPattern);
                foreach (var item in tMatch)
                {
                    pramList.Add(item.ToString());
                }

                oldItem.name           = formula.name;
                oldItem.formulaExp     = formulaStr;
                oldItem.operatorId     = AbpSession.UserId ?? 0;
                oldItem.lastModifyTime = DateTime.Now;
                _eleFormulaRep.Update(oldItem);

                int insertId = oldItem.Id;
                UpdatePrams(insertId, pramList);

                return
                    (new HtmlDataOperRetDto()
                {
                    Code = 1,
                    Message = "修改成功!"
                });
            }
            else
            {
                return
                    (new HtmlDataOperRetDto()
                {
                    Code = -1,
                    Message = "公式不合法!"
                });
            }
        }
        /// <summary>
        /// Retrieve a OrganisationType with associated lookups
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public OrganisationTypeVMDC GetOrganisationType(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <OrganisationType> dataRepository
                                                        , IRepository <OrganisationTypeGroup> organisationTypeGroupRepository
                                                        , IRepository <OrganisationType> parentOrganisationTypeRepository
                                                        , IExceptionManager exceptionManager, IMappingService mappingService)

        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    OrganisationTypeDC destination = null;

                    // If code is null then just return supporting lists
                    if (!string.IsNullOrEmpty(code))
                    {
                        // Convert code to Guid
                        Guid codeGuid = Guid.Parse(code);

                        // Retrieve specific OrganisationType
                        OrganisationType dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                        // Convert to data contract for passing through service interface
                        destination = mappingService.Map <OrganisationType, OrganisationTypeDC>(dataEntity);
                    }

                    IEnumerable <OrganisationTypeGroup> organisationTypeGroupList  = organisationTypeGroupRepository.GetAll(x => x.Name);
                    IEnumerable <OrganisationType>      parentOrganisationTypeList = parentOrganisationTypeRepository.GetAll(x => x.Name);

                    List <OrganisationTypeGroupDC> organisationTypeGroupDestinationList  = mappingService.Map <List <OrganisationTypeGroupDC> >(organisationTypeGroupList);
                    List <OrganisationTypeDC>      parentOrganisationTypeDestinationList = mappingService.Map <List <OrganisationTypeDC> >(parentOrganisationTypeList);

                    // Create aggregate contract
                    OrganisationTypeVMDC returnObject = new OrganisationTypeVMDC();

                    returnObject.OrganisationTypeItem       = destination;
                    returnObject.OrganisationTypeGroupList  = organisationTypeGroupDestinationList;
                    returnObject.ParentOrganisationTypeList = parentOrganisationTypeDestinationList;

                    return(returnObject);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
Beispiel #15
0
        private void InitForm()
        {
            if (MatchGuid != Guid.Empty)
            {
                var m = _repo.Single <Match>(MatchGuid);

                tbMatchGuid.Text = m.ID.ToString();

                if (m.LeagueGuid.HasValue)
                {
                    ddlLeague.SelectedValue = m.LeagueGuid.Value.ToString();
                    BindTeamData(m.LeagueGuid.Value);
                    ddlTeam.SelectedValue = m.TeamGuid.ToString();
                }
                else
                {
                    ddlLeague.SelectedValue = string.Empty;
                }

                cbIsHome.Checked = m.IsHome;

                if (m.Round.HasValue)
                {
                    tbRound.Text = m.Round.Value.ToString();
                }
                else
                {
                    tbRound.Text = string.Empty;
                }


                tbPlayTime.Text    = m.PlayTime.ToString("yyyy-MM-dd HH:mm");
                cbIsActive.Checked = m.IsActive;

                if (m.ResultHome.HasValue)
                {
                    tbResultHome.Text = m.ResultHome.Value.ToString();
                }
                else
                {
                    tbResultHome.Text = string.Empty;
                }

                if (m.ResultAway.HasValue)
                {
                    tbResultAway.Text = m.ResultAway.Value.ToString();
                }
                else
                {
                    tbResultAway.Text = string.Empty;
                }

                if (m.CasinoMatchGuid.HasValue)
                {
                    tbCasinoMatchGuid.Text = m.CasinoMatchGuid.Value.ToString();
                }
                else
                {
                    tbCasinoMatchGuid.Text = string.Empty;
                }

                if (m.GroupGuid.HasValue)
                {
                    tbGroupGuid.Text = m.GroupGuid.Value.ToString();
                }
                else
                {
                    tbGroupGuid.Text = string.Empty;
                }

                tbReportImageURL.Text = m.ReportImageURL;
                tbReportURL.Text      = m.ReportURL;
                tbTopicURL.Text       = m.TopicURL;
                tbRemark.Text         = m.Remark;
            }
            else
            {
                tbMatchGuid.Text = Guid.NewGuid().ToString();
            }
        }
 public async Task <Client> FindClientByIdAsync(string clientId)
 {
     return(await repository.Single <Client>(x => x.ClientId == clientId));
 }
Beispiel #17
0
        public async Task <GetActiveSessionResponse> GetActiveSession()
        {
            var activeSession = await _sessionRepository.Single(x => x.Start <= DateTime.UtcNow && x.ActualEnd >= DateTime.UtcNow);

            return(_getActiveSessionResponseMapper.Map(activeSession));
        }
        private void InitForm()
        {
            try
            {
                lblMemberName.Text    = $"<b>{MemberName}</b> (<em>NO.{Mid}</em>)";
                lblMemberACNInfo.Text = $"<b>{Username}</b> (<em>ID.{Uid}</em>)";

                if (OrderID > 0)
                {
                    var o = (OrdrWish)Order.Select(OrderID);

                    if (o == null || !o.IsActive)
                    {
                        throw new Exception("此订单无效");
                    }

                    if (ConfigGlobal.IsPluginAdmin(Uid) || o.MemberID.Equals(Mid))
                    {
                        lblMemberName.Text = $"<b>{o.MemberName}</b> (<em>NO.{o.MemberID}</em>)";

                        var m = _repo.Single <Member>(o.MemberID);

                        if (m == null || !m.IsActive)
                        {
                            throw new Exception("无此会员信息");
                        }

                        lblMemberACNInfo.Text = $"<b>{m.AcnName}</b> (<em>ID.{m.AcnID}</em>)";
                        tbMemberWeChat.Text   = m.WeChat;
                    }
                    else
                    {
                        throw new Exception("此订单非当前用户订单");
                    }

                    tbOrderMobile.Text  = o.Mobile;
                    tbOrderAddress.Text = o.Address;

                    rblOrderPostage.SelectedValue = o.Postage > 0 ? o.Postage.ToString("f0") : "23";

                    tbOrderDescription.Text = o.Description;

                    var query = _repo.Query <OrderItem>(x => x.OrderID == o.ID).FindAll(x => x.IsActive).OrderBy(x => x.ID);

                    if (query.Any())
                    {
                        var jsonSerializer = new JavaScriptSerializer();
                        tbWishOrderItemListInfo.Text = jsonSerializer.Serialize(query.ToList());
                    }
                    else
                    {
                        tbWishOrderItemListInfo.Text = string.Empty;
                    }
                }
                else
                {
                    //Fill Member draft information into textbox
                    var m = _repo.Single <Member>(Mid);

                    tbOrderMobile.Text  = m.Mobile;
                    tbMemberWeChat.Text = m.WeChat;
                    tbOrderAddress.Text = m.Address;
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "failed",
                                                       $"alert('{ex.Message}');window.location.href = 'Default.aspx'", true);
            }
        }
Beispiel #19
0
        public int AllocateCase(Task task)
        {
            Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> Processing AllocateCase.");
            var prfMonMethod = new PrfMon();

            var site = _siteRepository.Single(x => x.Pin == task.Pin.Value);

            using (var context = new ClientContext(SiteCollectionUrl(site.ProvisionedSite.ProvisionedSiteCollection.Name)))
            {
                var web = _contextService.Load(context, Credentials);

                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> CheckRequiredSecurityGroupsExist. Started.");
                var obtainRequiredUsersPrfMonTriggers = new PrfMon();
                var spSite   = web.Webs.Single(x => x.Url == site.Url);
                var colGroup = spSite.SiteGroups;
                context.Load(colGroup);
                var globalSystemsAdminUser         = web.EnsureUser(_parameterService.GetParameterByNameAndCache <string>(ParameterNames.ActiveDirectoryGlobalSystemsAdministratorGroup));
                var activeDirectoryContributeGroup = _parameterService.GetParameterByNameAndCache <string>(ParameterNames.ActiveDirectoryContributeGroup);
                var activeDirectoryReadGroup       = _parameterService.GetParameterByNameAndCache <string>(ParameterNames.ActiveDirectoryReadGroup);
                var projectContributorsGroup       = web.GetActiveDirectoryGroup(activeDirectoryContributeGroup, site.RestrictedUser, site.Pin, task.ProjectId.Value);
                var projectReadGroup   = web.GetActiveDirectoryGroup(activeDirectoryReadGroup, site.RestrictedUser, site.Pin, task.ProjectId.Value);
                var spPinVisitorsGroup = colGroup.GetByName(string.Format(SharePointPinGroupNames.PinVisitors, site.Pin));
                context.Load(spSite, s => s.Lists.Include(l => l.Title));
                context.ExecuteQuery();
                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> CheckRequiredSecurityGroupsExist. Completed. Average Execution: {0:0.000}s", obtainRequiredUsersPrfMonTriggers.Stop());

                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> CreateDocumentLibrary. Started.");
                var createDocumentLibraryPrfMonTriggers = new PrfMon();
                var documentLibraryList = spSite.CreateDocumentLibrary(task.CaseId.Value.ToString());
                context.Load(documentLibraryList, d => d.ContentTypes);
                context.ExecuteQuery();
                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> CreateDocumentLibrary. Completed. Average Execution: {0:0.000}s", createDocumentLibraryPrfMonTriggers.Stop());

                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> UpdateDocumentLibraryList. Started.");
                var updateDocumentLibraryPrfMonTriggers = new PrfMon();
                documentLibraryList.UpdateDocumentLibraryList(web.ContentTypes, ContentTypeGroupNames.CaseDocumentContentTypes, task.CaseTitle);
                context.Load(documentLibraryList, d => d.Id, d => d.Fields);
                var folders = _parameterService.GetParameterByNameAndCache <string>(ParameterNames.CaseLibraryFolderNames);
                documentLibraryList.AddFolders(folders);
                context.ExecuteQuery();
                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> UpdateDocumentLibraryList. Completed. Average Execution: {0:0.000}s", updateDocumentLibraryPrfMonTriggers.Stop());

                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> UpdateDocumentLibraryMetaData. Started.");
                var documentLibraryMetaDataPrfMonTriggers = new PrfMon();
                var dictionary = context.CreateDocumentLibraryMetaData(documentLibraryList, spSite, task.Dictionary);
                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> UpdateDocumentLibraryMetaData. Completed. Average Execution: {0:0.000}s", documentLibraryMetaDataPrfMonTriggers.Stop());

                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> AssignPinMembershipPermissions. Started.");
                var assignPinMembershipPermissionsPrfMonTriggers = new PrfMon();
                if (task.IsPrimary.Value || !task.IsPrimary.Value && site.PrimaryProjectId != null && site.PrimaryProjectId == task.ProjectId.Value)
                {
                    var spPinMembersGroup = colGroup.GetByName(string.Format(SharePointPinGroupNames.PinMembers, site.Pin));
                    context.Load(spPinMembersGroup.Users, x => x.Include(u => u.Id, u => u.PrincipalType, u => u.Title));
                    context.ExecuteQuery();
                    var groupIds = spPinMembersGroup.Users.Where(u => u.PrincipalType == PrincipalType.SecurityGroup &&
                                                                 u.Title.EndsWith("_CONTRIBUTE") || u.Title.EndsWith("_CONTRIBUTE_CLOSED") ||
                                                                 u.Title.EndsWith($"_CONTRIBUTE_{site.Pin}") || u.Title.EndsWith($"_CONTRIBUTE_CLOSED_{site.Pin}")).Select(s => s.Id).ToList();
                    foreach (var id in groupIds)
                    {
                        spPinMembersGroup.Users.RemoveById(id);
                    }
                    if (task.IsPrimary.Value)
                    {
                        spPinMembersGroup.Users.AddUser(projectContributorsGroup);
                    }
                }
                context.Load(spPinVisitorsGroup);
                spPinVisitorsGroup.Users.AddUser(projectReadGroup);
                context.Load(documentLibraryList.RoleAssignments);
                context.ExecuteQuery();
                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> AssignPinMembershipPermissions. Completed. Average Execution: {0:0.000}s", assignPinMembershipPermissionsPrfMonTriggers.Stop());

                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> SetupDocumentLibraryMembershipPermissions. Started.");
                var setupDocumentLibraryMembershipPermissionsPrfMonTriggers = new PrfMon();
                documentLibraryList.BreakRoleInheritanceAndRemoveRoles(true, false, true);
                documentLibraryList.AddRoleWithPermissions(context, web, globalSystemsAdminUser, RoleType.Contributor);
                documentLibraryList.AddRoleWithPermissions(context, web, projectContributorsGroup, RoleType.Contributor);
                documentLibraryList.AddRoleWithPermissions(context, web, spPinVisitorsGroup, RoleType.Reader);
                documentLibraryList.Update();
                context.ExecuteQuery();
                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> SetupDocumentLibraryMembershipPermissions. Completed. Average Execution: {0:0.000}s", setupDocumentLibraryMembershipPermissionsPrfMonTriggers.Stop());

                _contextService.Audit(context, task, string.Format(TaskResources.Audit_AllocateCase, site.Pin, task.CaseId.Value, task.CaseTitle));

                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> DatabaseSynchronisation. Started.");
                var databaseSynchronisationPrfMonTriggers = new PrfMon();
                var now     = DateTime.Now;
                var library = new Library
                {
                    CaseId       = task.CaseId.Value,
                    Title        = task.CaseTitle,
                    ProjectId    = task.ProjectId.Value,
                    SiteId       = site.Id,
                    ListId       = documentLibraryList.Id,
                    IsClosed     = false,
                    Url          = $"{CaseDocumentLibraryUrl(site.ProvisionedSite.ProvisionedSiteCollection.Name, site.Pin.ToString(), task.CaseId.Value.ToString())}",
                    Dictionary   = dictionary,
                    InsertedDate = now,
                    InsertedBy   = _userIdentity.Name,
                    UpdatedDate  = now,
                    UpdatedBy    = _userIdentity.Name
                };
                RetryableOperation.Invoke(ExceptionPolicies.General,
                                          () =>
                {
                    if (task.IsPrimary.Value && (site.PrimaryProjectId == null || site.PrimaryProjectId.Value != task.ProjectId.Value))
                    {
                        site.PrimaryProjectId = task.ProjectId;
                        site.UpdatedDate      = now;
                        site.UpdatedBy        = _userIdentity.Name;
                        _siteRepository.Update(site);
                    }
                    else if (!task.IsPrimary.Value && site.PrimaryProjectId != null && site.PrimaryProjectId == task.ProjectId.Value)
                    {
                        site.PrimaryProjectId = null;
                        site.UpdatedDate      = now;
                        site.UpdatedBy        = _userIdentity.Name;
                        _siteRepository.Update(site);
                    }

                    _libraryRepository.Insert(library);
                    _unitOfWork.Save();
                });
                Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> DatabaseSynchronisation. Completed. Average Execution: {0:0.000}s", databaseSynchronisationPrfMonTriggers.Stop());
            }

            Debug.WriteLine("Fujitsu.AFC.Services.CaseService.cs -> Completed Processing AllocateCase. Duration: {0:0.000}s", prfMonMethod.Stop());
            return(site.Id);
        }
        /// <summary>
        /// Retrieve a LinkedCustomer with associated lookups
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public LinkedCustomerVMDC GetLinkedCustomer(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <LinkedCustomer> dataRepository
                                                    , IRepository <Customer> customer1Repository
                                                    , IRepository <Customer> customer2Repository
                                                    , IExceptionManager exceptionManager, IMappingService mappingService)

        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    LinkedCustomerDC destination = null;

                    // If code is null then just return supporting lists
                    if (!string.IsNullOrEmpty(code))
                    {
                        // Convert code to Guid
                        Guid codeGuid = Guid.Parse(code);

                        // Retrieve specific LinkedCustomer
                        LinkedCustomer dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                        // Convert to data contract for passing through service interface
                        destination = mappingService.Map <LinkedCustomer, LinkedCustomerDC>(dataEntity);
                    }

                    IEnumerable <Customer> customer1List = customer1Repository.GetAll(x => new { x.Title });
                    IEnumerable <Customer> customer2List = customer2Repository.GetAll(x => new { x.Title });

                    List <CustomerDC> customer1DestinationList = mappingService.Map <List <CustomerDC> >(customer1List);
                    List <CustomerDC> customer2DestinationList = mappingService.Map <List <CustomerDC> >(customer2List);

                    // Create aggregate contract
                    LinkedCustomerVMDC returnObject = new LinkedCustomerVMDC();

                    returnObject.LinkedCustomerItem = destination;
                    returnObject.Customer1List      = customer1DestinationList;
                    returnObject.Customer2List      = customer2DestinationList;

                    return(returnObject);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
Beispiel #21
0
 public FooterViewModel GetFooter()
 {
     return(Mapper.Map <Footer, FooterViewModel>(_footerRepository.Single(x => x.Id ==
                                                                          CommonConstants.DefaultFooterId)));
 }
Beispiel #22
0
 public Category Default()
 {
     return(_sonicRepo.Single <Category>("default"));
 }
Beispiel #23
0
        public void Should_Write_History_For_Owned_Entity_Of_Audited_Entities_Create()
        {
            // Blog is the owner of BlogEx and has Audited attribute.
            // Therefore, BlogEx should follow Blog and have entity history.

            //Arrange
            int blog2Id;

            using (var uow = Resolve <IUnitOfWorkManager>().Begin())
            {
                // Owned entities are not available via DbContext -> DbSet,
                var blog2 = _blogRepository.Single(b => b.Name == "test-blog-2");
                blog2Id = blog2.Id;
                blog2.More.ShouldBeNull();

                blog2.More = new BlogEx()
                {
                    BloggerName = "blogger-2"
                };
                uow.Complete();
            };

            //Assert
            WithUnitOfWork(() =>
            {
                // Owned entities are not available via DbContext -> DbSet,
                var blog2 = _blogRepository.Single(b => b.Name == "test-blog-2");
                blog2.More.ShouldNotBeNull();
            });

            Predicate <EntityChangeSet> predicate = s =>
            {
                s.EntityChanges.Count.ShouldBe(1);

                var entityChange = s.EntityChanges.Single(ec => ec.EntityTypeFullName == typeof(BlogEx).FullName);
                entityChange.ChangeType.ShouldBe(EntityChangeType.Created);
                // The primary key of BlogEx is a shadow property,
                // EF Core is keeping the values of PK of Blog and PK of BlogEx the same
                // See https://docs.microsoft.com/en-us/ef/core/modeling/owned-entities#implicit-keys
                entityChange.EntityId.ShouldBe(blog2Id.ToJsonString(false, false));
                entityChange.PropertyChanges.Count.ShouldBe(1);

                var propertyChange = entityChange.PropertyChanges.Single(pc => pc.PropertyName == nameof(BlogEx.BloggerName));
                propertyChange.OriginalValue.ShouldBeNull();
                propertyChange.NewValue.ShouldBe("blogger-2".ToJsonString(false, false));
                propertyChange.PropertyTypeFullName.ShouldBe(typeof(BlogEx).GetProperty(nameof(BlogEx.BloggerName)).PropertyType.FullName);

                return(true);
            };

            _entityHistoryStore.Received().Save(Arg.Is <EntityChangeSet>(s => predicate(s)));
        }
Beispiel #24
0
 public Room GetById(string companyId, string id)
 {
     return(_roomRepository.Single <Room>(k => k.Id == id && k.CompanyId == companyId));
 }
Beispiel #25
0
 public OrderDto GetOrder(Guid id)
 {
     return(_mapper.Map <OrderDto>(_repository.Single(x => x.Id == id)));
 }
        //
        // GET: /OutgoingMessage/Details/5

        public ViewResult Details(string id)
        {
            OutgoingMessage msg = repository.Single <OutgoingMessage>(o => o.Id == id);

            return(View(msg));
        }
        /// <summary>
        /// Retrieve a LastUpdate with associated lookups
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public LastUpdateVMDC GetLastUpdate(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <LastUpdate> dataRepository
                                            )

        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }

                #endregion

                using (uow)
                {
                    LastUpdateDC destination = null;

                    // If code is null then just return supporting lists
                    if (!string.IsNullOrEmpty(code))
                    {
                        // Convert code to Guid
                        Guid codeGuid = Guid.Parse(code);

                        // Retrieve specific LastUpdate
                        LastUpdate dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                        // Convert to data contract for passing through service interface
                        destination = Mapper.Map <LastUpdate, LastUpdateDC>(dataEntity);
                    }



                    // Create aggregate contract
                    LastUpdateVMDC returnObject = new LastUpdateVMDC();

                    returnObject.LastUpdateItem = destination;

                    return(returnObject);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                ExceptionManager.ShieldException(e);

                return(null);
            }
        }
Beispiel #28
0
 public ConfigService(IRepository repository)
 {
     _repository = repository;
     Current = _repository.Single<Config, string>("settings");
 }
Beispiel #29
0
        /// <summary>
        /// Update a SiteStaff
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="lockID"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        public void DeleteSiteStaff(string currentUser, string user, string appID, string overrideID, string code, string lockID, IRepository <SiteStaff> dataRepository, IUnitOfWork uow, IExceptionManager exceptionManager, IMappingService mappingService)
        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (string.IsNullOrEmpty(code))
                {
                    throw new ArgumentOutOfRangeException("code");
                }
                if (string.IsNullOrEmpty(lockID))
                {
                    throw new ArgumentOutOfRangeException("lockID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    // Convert string to guid
                    Guid codeGuid = Guid.Parse(code);

                    // Find item based on ID
                    SiteStaff dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                    // Delete the item
                    dataRepository.Delete(dataEntity);

                    // Commit unit of work
                    uow.Commit();
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);
            }
        }
Beispiel #30
0
 public TEntity Get(Expression <Func <TEntity, bool> > predicate)
 {
     return(_repository.Single(predicate));
 }
        public HomeViewModel(ILog log, IAccount account, ILocalize localize, IApplication application, IHistory history,
                             INavigationService navigationService, IUser user, IRepository repository,
                             IList<IExerciseType> exerciseTypes, ISettings settings)
        {
            _log = log;
            _localize = localize;
            _application = application;
            Account = account;

            _history = history;
            _history.OnHistoryItemsChanged += _history_OnHistoryItemsChanged;
            _NavigationService = navigationService;
            User = user;
            ExerciseTypes = exerciseTypes;
            _repository = repository;
            _settings = settings;
            _settings.OnSettingsChanged += _settings_OnSettingsChanged;
            _settings.Load();
            _history.Load();

            _repository.Single<User>(1).ContinueWith(t =>
                {
                    var foundUser = t.Result;
                    if (foundUser == null)
                    {
                        //this is first load of the app, set it up
                        _repository.Insert<User>(this.User).ContinueWith(task =>
                            {
                                this.User = this.User;
                                Account.AccessToken = this.User.RunkeeperToken;

                            });
                    }
                    else
                    {
                        User = foundUser;
                        Account.AccessToken = foundUser.RunkeeperToken;
                    }
                });

            if (_exerciseTypes == null || _exerciseTypes.Count == 0 ||
                (_exerciseTypes.Count == 1 && _exerciseTypes[0].Id == 0))
            {
                if (HomeViewModel.cachedTypes != null)
                {
                    this.ExerciseTypes = HomeViewModel.cachedTypes;
                    _log.Info("cache hit");
                }
                else
                {
                    _log.Info("cache miss");
                    this.ExerciseTypes = DefaultTypes;
                    _log.Info("default types set, querying");
                    _repository.Query<ExerciseType>("select * from ExerciseType").ContinueWith(t =>
                        {
                            _log.Info("query complete");
                            var types = t.Result;
                            if (types == null || types.Count == 0)
                            {

                                _log.Info("db does not have Exercise types, loading default items");
                                foreach (var e in from tt in this.ExerciseTypes orderby tt.Id select tt)
                                {
                                    _repository.Insert<ExerciseType>(e);
                                }
                            }
                            else
                            {
                                _log.Info("all excecise types retreived from the db, update local data store");
                                this.ExerciseTypes = (from tt in types select tt).ToArray();
                            }
                            _log.Info("cache extypes to static var");
                            HomeViewModel.cachedTypes = ExerciseTypes;

                        });
                }
            }
        }
 public TEntity Single(Expression <Func <TEntity, bool> > where)
 {
     return(_iRepository.Single(where));
 }