public IEnumerable <ModelView.ReportChartModel> ChartWorkShopCountByReserv(IConnectionHandler connectionHandler, Guid congressId) { List <ModelView.ReportChartModel> listout = new List <ModelView.ReportChartModel>(); List <dynamic> list = GroupBy(connectionHandler, new Expression <Func <WorkShopUser, object> >[] { x => x.WorkShop.Subject }, new GroupByModel <WorkShopUser>[] { new GroupByModel <WorkShopUser>() { Expression = x => x.WorkShopId, AggrigateFuntionType = AggrigateFuntionType.Count }, }, x => x.WorkShop.CongressId == congressId); List <dynamic> allType = new WorkShopBO().Select(connectionHandler, new Expression <Func <WorkShop, object> >[] { x => x.Subject }, x => x.CongressId == congressId); foreach (dynamic item in allType) { dynamic first = list.FirstOrDefault(x => (x.Subject is string) && (string)x.Subject == (string)item.Subject); listout.Add(new ModelView.ReportChartModel() { Count = first?.CountWorkShopId ?? 0, Value = (string)item.Subject }); } return(listout); }
public CongressXml GetXmlData(IConnectionHandler connectionHandler) { var homaXml = new CongressXml { AttendanceType = new List <KeyValueXml>() { new KeyValueXml() { Key = "Congress", Value = "همایش" }, new KeyValueXml() { Key = "WorkShop", Value = "کارگاه" }, } }; var currentCongress = new HomaBO().GetCurrentCongress(connectionHandler); foreach (var homa in currentCongress) { var congressModelXml = new CongressModelXml() { CongressId = homa.Id, Title = homa.CongressTitle }; var users = new UserBO().SelectKeyValuePair(connectionHandler, x => x.Number, x => x.EnterpriseNode.RealEnterpriseNode.FirstName + " " + x.EnterpriseNode.RealEnterpriseNode.LastName + "(" + x.Username + ")", x => x.CongressId == homa.Id); foreach (var user in users) { congressModelXml.UserList.Add(new KeyValueXml() { Value = user.Value, Key = user.Key }); } var @where = new WorkShopBO().Where(connectionHandler, x => x.CongressId == homa.Id); foreach (var shop in @where) { var shopModelXml = new WorkShopModelXml() { Key = shop.Id.ToString(), Value = shop.Subject }; var shopUsers = new WorkShopUserBO().SelectKeyValuePair(connectionHandler, x => x.User.Number, x => x.User.EnterpriseNode.RealEnterpriseNode.FirstName + " " + x.User.EnterpriseNode.RealEnterpriseNode.LastName + "(" + x.User.Username + ")", x => x.WorkShopId == shop.Id); foreach (var user in shopUsers) { shopModelXml.UserList.Add(new KeyValueXml() { Value = user.Value, Key = user.Key }); } congressModelXml.WorkShopModelList.Add(shopModelXml); } homaXml.CongressModelXml.Add(congressModelXml); } return(homaXml); }
public KeyValuePair <bool, Guid> WorkShopUserInsert(IConnectionHandler connectionHandler, IConnectionHandler paymentConnection, IConnectionHandler formGeneratorConnection, Guid workShopId, User parentUser, List <DiscountType> discountAttaches, string callBackurl, FormStructure formModel, List <Guid> users) { Guid? outvalue = null; WorkShopBO workShopBo = new WorkShopBO(); WorkShop workShop = workShopBo.Get(connectionHandler, workShopId); int newlistCount = 0; List <Guid> validlist = new List <Guid>(); Payment.Facade.Interface.ITempFacade tempTransactionalFacade = PaymentComponenets.Instance.TempTransactionalFacade(paymentConnection); List <Guid> @select = Select(connectionHandler, x => x.UserId, x => x.WorkShopId == workShopId); CongressDiscountTypeBO congressDiscountTypeBo = new CongressDiscountTypeBO(); string additionalData = congressDiscountTypeBo.FillTempAdditionalData(connectionHandler, workShop.CongressId); foreach (Guid guid1 in users) { bool hotelUser = @select.Any(x => x == guid1); if (!hotelUser) { newlistCount++; validlist.Add(guid1); } else { validlist.Add(guid1); } } if (workShop.FreeCapicity < newlistCount) { throw new Exception(Resources.Congress.WorkShopCapacityLessThanNumberOfSelectedUser); } List <WorkShopUser> list = Where(connectionHandler, x => (x.UserId == parentUser.Id || x.User.ParentId == parentUser.Id) && x.WorkShopId == workShopId, true); foreach (WorkShopUser workShopUser in list) { if (validlist.Any(x => x.Equals(workShopUser.UserId))) { continue; } if (workShopUser.Status != (byte)Enums.WorkShopRezervState.RegisterRequest && workShopUser.Status != (byte)Enums.WorkShopRezervState.DenialPay) { continue; } if (workShopUser.TempId.HasValue) { tempTransactionalFacade.Delete(workShopUser.TempId); } if (!base.Delete(connectionHandler, workShopUser)) { throw new Exception(Resources.Congress.ErrorInReservWorkShop); } } if (workShop.ValidCost.ToDecimal() > 0 && validlist.Any()) { outvalue = SelectFirstOrDefault(connectionHandler, x => x.TempId, x => x.UserId.In(validlist) && x.WorkShopId == workShopId); decimal calulateAmountNew = congressDiscountTypeBo.CalulateAmountNew(paymentConnection, (workShop.ValidCost.ToDecimal()) * validlist.Count, discountAttaches); if (outvalue == null) { outvalue = Guid.NewGuid(); Temp temp = new Temp { Id = (Guid)outvalue, PayerId = parentUser.Id, CallBackUrl = callBackurl + outvalue, Description = Resources.Congress.PaymentWorkShopReserv + " " + workShop.Subject, PayerTitle = parentUser.DescriptionField, Amount = calulateAmountNew, CurrencyType = (byte)workShop.CurrencyType.ToEnum <Radyn.Common.Definition.Enums.CurrencyType>(), AdditionalData = additionalData }; if (!tempTransactionalFacade.Insert(temp, discountAttaches)) { return(new KeyValuePair <bool, Guid>(false, Guid.Empty)); } } else { Temp tr = tempTransactionalFacade.Get(outvalue); tr.Amount = calulateAmountNew; tr.CurrencyType = (byte)workShop.CurrencyType.ToEnum <Radyn.Common.Definition.Enums.CurrencyType>(); tr.AdditionalData = additionalData; if (!tempTransactionalFacade.Update(tr, discountAttaches)) { return(new KeyValuePair <bool, Guid>(false, Guid.Empty)); } } } FormGenerator.Facade.Interface.IFormDataFacade formDataTransactionalFacade = FormGeneratorComponent.Instance.FormDataTransactionalFacade(formGeneratorConnection); List <WorkShopUser> @selectd = Where(connectionHandler, x => x.WorkShopId == workShopId && x.UserId.In(validlist), true); foreach (Guid id in validlist) { WorkShopUser workShopUser = @selectd.FirstOrDefault(x => x.UserId == id); if (workShopUser == null) { WorkShopUser shopUser = new WorkShopUser() { UserId = id, WorkShopId = workShopId }; if (outvalue != null) { shopUser.TempId = outvalue; } else { shopUser.TempId = null; shopUser.Status = (byte)Enums.WorkShopRezervState.PayConfirm; } if (!Insert(connectionHandler, shopUser)) { throw new Exception(Resources.Congress.ErrorInReservWorkShop); } } else { if (outvalue != null) { workShopUser.TempId = outvalue; } else { if (workShopUser.TempId.HasValue) { tempTransactionalFacade.Delete(workShopUser.TempId); } workShopUser.TempId = null; workShopUser.Status = (byte)Enums.WorkShopRezervState.PayConfirm; } if (!Update(connectionHandler, workShopUser)) { throw new Exception(Resources.Congress.ErrorInReservWorkShop); } } formModel.RefId = id + "," + workShopId; if (!formDataTransactionalFacade.ModifyFormData(formModel)) { throw new Exception(Resources.Congress.ErrorInReservWorkShop); } } return(new KeyValuePair <bool, Guid>(true, outvalue != null ? (Guid)outvalue : Guid.Empty)); }