protected virtual async void PayWithCard() { var paymentParams = VmService.GetPaymentParams(PaymentInfo.Amount, PaymentInfo.Currency, OrderId, PaymentInfo.Items, PaymentInfo.CustomerPhone); PaymentParams = new FormUrlEncodedContent(paymentParams); PaymentUrl = YandexKassaConstants.PAY_URL; }
public ActionResult ServiceMessage(VmService message) { if (ModelState.IsValid) { Appointment appointment = new Appointment(); appointment.CreatedDate = DateTime.UtcNow.AddHours(4); appointment.DateAndTime = DateTime.ParseExact(message.Appointment.DateAndTimeNotMapped, "dd.MM.yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture); appointment.Email = message.Appointment.Email; appointment.Name = message.Appointment.Name; appointment.Message = message.Appointment.Message; appointment.Phone = message.Appointment.Phone; appointment.ServiceId = message.ServiceId; db.Appointments.Add(appointment); db.SaveChanges(); Session["Success"] = true; } else { Session["Required"] = true; } return(RedirectToAction("ServiceDetails", new { Id = message.ServiceId })); }
public async Task <IActionResult> RequestVm(Vm newVm) { if (!ModelState.IsValid) { return(BadRequest(ModelState.ToString())); } if (newVm?.Cluster?.Datacenter?.Adapter == null) { return(BadRequest("Неверно заполнены поля")); } #region CheckResponsibles // Проверка на корректность задания ответственных: администратора, менеджера и владельца var responsibles = new List <User>() { newVm.Admin, newVm.Manager, newVm.Owner }; responsibles = responsibles.GroupBy(x => x.Sam).Select(x => x.FirstOrDefault()).ToList(); List <User> users = _authService.GetUsersList(responsibles); if (responsibles.Count != users.Count) { return(BadRequest("Неверно заполнены поля ответственных за ВМ. Пожалуйста, выберите тех, кто есть в списке")); } #endregion Adapter adapter = await _context.Adapters.Where(x => x.IsOK).Include(c => c.Credentials) .Include(p => p.Provider) .Where(a => a.Id == newVm.Cluster.Datacenter.Adapter.Id) .SingleOrDefaultAsync(); var auditDays = (await _context.Audits.SingleOrDefaultAsync(x => x.AdapterId == adapter.Id && x.DatacenterId == newVm.Cluster.Datacenter.Id && x.ClusterId == newVm.Cluster.Id))?.AuditDays; if (auditDays != null) { newVm.AuditDate = DateTime.Now.ToShortDateString(); newVm.Deadline = DateTime.Now.AddDays((double)auditDays).ToShortDateString(); } var user = User.Claims.SingleOrDefault(x => x.Type == ClaimTypes.Name).Value; switch (adapter.Provider.Id) { case (int)ProviderType.Ovirt: ServicesResponse newVmResponse = await VmService.RequestVm(newVm, adapter, newVm.Network.Id, newVm.HddSize, newVm.Cluster.Datacenter.Id); if (!newVmResponse.isSuccess) { return(StatusCode(newVmResponse.errorCode, newVmResponse.errorMessage)); } break; case (int)ProviderType.VMware: var task = await SendVmRequest(adapter, newVm, user); TrackBackendTask(adapter, task); break; } _mailer.NotifyVmRequested(users, newVm); return(CreatedAtAction("RequestVm", newVm)); }
public async Task <IActionResult> Remove(Vm vM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (vM?.Adapter == null) { return(BadRequest()); } Adapter adapter = await _context.Adapters.Where(x => x.IsOK) .Include(c => c.Credentials) .Include(p => p.Provider) .Where(a => a.Id == vM.Adapter.Id) .SingleOrDefaultAsync(); ServicesResponse shutdownVmResponse = new ServicesResponse(); switch (adapter.Provider.Name.ToLower()) { case "ovirt": shutdownVmResponse = await VmService.RemoveVm(adapter, vM.Id); if (!shutdownVmResponse.isSuccess) { return(BadRequest(shutdownVmResponse.errorMessage)); } break; } return(Ok(shutdownVmResponse)); }
protected virtual async void OnSettingsValueChanged(ISettingsItemVm item) { switch (item.ElementType) { case SettingsElementType.Region: //var regionId = ((ISettingsPickerVm)item).SelectedValueId; //AppSettings.RegionID = regionId; //ChangeRegionHeaderTo(regionId); break; case SettingsElementType.Geolocation: AppSettings.IsGeolocationEnabled = ((SettingsSwitchVm)item).Enabled; break; case SettingsElementType.Notifications: try { if (_notificationCTS != null) { _notificationCTS.Cancel(); } _notificationCTS = new CancellationTokenSource(); var enabled = ((SettingsSwitchVm)item).Enabled; await VmService.ChangeNotifications(enabled, _notificationCTS.Token); AppSettings.IsNotificationsEnabled = enabled; } catch (OperationCanceledException) { } break; } }
protected virtual async Task HandleUrlChange(string url) { if (await VmService.ProcessPayment(url)) { await PaymentsVmService.OrderPaid(OrderId); } }
protected virtual async void OnArticleSelected(Article article) { Loading = true; await VmService.HandleSelection(article); Loading = false; }
protected override async Task LoadContent() { Loading = true; Items = await VmService.LoadPoints(null, 0, 100); Loading = false; }
public IServiceResultWrap GetServiceStatus([FromBody] VmService model) { return(serviceManager.CallService( () => new ServiceLocalizedResultWrap(model) { Data = service.GetServiceStatus(model.Id.Value), }, new Dictionary <Type, string>())); }
public IServiceResultWrap IsServiceEditable([FromBody] VmService model) { return(serviceManager.CallService( () => new ServiceResultWrap() { Data = model.Id != null ? service.IsServiceEditable(model.Id.Value) : null, }, new Dictionary <Type, string>())); }
private void CheckTranslation(VmService source, VmServiceStep2 step, ServiceVersioned target) { //target.Id.Should().NotBe(Guid.Empty); target.ServiceTargetGroups.Count.Should().Be(step.TargetGroups.Count); target.ServiceServiceClasses.Count.Should().Be(step.ServiceClasses.Count); target.ServiceOntologyTerms.Count.Should().Be(step.OntologyTerms.Count); target.ServiceLifeEvents.Count.Should().Be(step.LifeEvents.Count); target.ServiceKeywords.Count.Should().Be(step.KeyWords.Count); }
protected virtual async Task LoadContent() { Loading = true; var dataSource = await VmService.LoadArticles(); InvokeOnMainThread(() => Articles = dataSource); Loading = false; }
private async Task LoadContent() { Loading = true; var dataSource = await VmService.LoadFiltersFor(_categoryId, ApplyedFilters); InvokeOnMainThread(() => Items = dataSource); Loading = false; }
protected override async Task LoadContent() { Loading = true; Items = await VmService.LoadPoints(SearchText, 0, LOADING_COUNT); CanLoadMore = !Items.IsNullOrEmpty() && Items.Count >= LOADING_COUNT; LoadMoreCommand.RaiseCanExecuteChanged(); Loading = false; }
protected override Task LoadMoreContent() { return(Task.Run(async() => { var moreItems = await VmService.LoadPoints(SearchText, Items?.Count ?? 0, LOADING_COUNT); InvokeOnMainThread(() => Items.AddRange(moreItems)); CanLoadMore = !moreItems.IsNullOrEmpty() && moreItems.Count == LOADING_COUNT; LoadMoreCommand.RaiseCanExecuteChanged(); })); }
public IServiceResultWrap SaveAllChanges([FromBody] VmService model) { return(serviceManager.CallService( () => new ServiceLocalizedResultWrap(model) { Data = service.AddService(model), }, new Dictionary <Type, string>() { { typeof(string), MessageAddService }, { typeof(RoleActionException), MessageAddServiceRole } })); }
protected virtual async Task Purchase() { var oid = await VmService.RegisterOrder(PaymentInfo.Amount, PaymentInfo.Currency == "RUB"? 643 : 0, PaymentInfo.CustomerEmail, PaymentInfo.CustomerPhone, OrderId); if (oid != 0) { PaymentUrl = VmService.GetPurchaseUrl(oid, PaymentInfo.CustomerEmail); } else { await UserDialogs.Error("Не удалось произвести оплату"); } }
public IServiceResultWrap SaveStep4Changes([FromBody] VmService model) { return(serviceManager.CallService( () => new ServiceLocalizedResultWrap(model) { Data = service.SaveStep4Changes(model.Id.Value, model.Step4Form), }, new Dictionary <Type, string>() { { typeof(string), MessageSaveServiceStep }, { typeof(LockException), MessageLockedService }, { typeof(RoleActionException), MessageSaveServiceRole } })); }
protected virtual void OnApplyExecute() { if (Items != null && Items.Any()) { ApplyedFilters = Items .Where(x => x.SelectedValue != null) .Select(x => x.SelectedValue) .ToList(); VmService.ChangeFiltersTo(_categoryId, ApplyedFilters); } Close(this); }
protected virtual void OnClearExecute() { ApplyedFilters = new List <ApplyedFilter>(); Items?.ForEach(x => x.ClearSelectedValue()); Messenger.Publish(new FiltersReloadWhenValueChangedMessage(this)); if (Config.ApplyFiltersWhenClearingUp) { VmService.ChangeFiltersTo(_categoryId, ApplyedFilters); Close(this); } }
protected virtual async Task ProcessCardPayment(PaymentOrderInfo paymentInfo) { Loading = true; if (await VmService.PayWithCard(CardNumber.Without(' '), ExpirationDate, Cvv, CardHolder, paymentInfo.Amount, paymentInfo.Currency, () => { Loading = false; })) { UserDialogs.Confirm($"Заказ №{OrderId} успешно оплачен", "ОК"); //TODO переходить на экран успеха this.ChangePresentation(new MoveToDefaultPH()); } Loading = false; }
private void CheckTranslation(VmService source, VmServiceStep1 step1, ServiceVersioned target) { //target.Id.Should().NotBe(Guid.Empty); var names = conversion.GetValidTextsSkipEmptyKeepMandatory(step1.ServiceName, step1.AlternateServiceName); target.ServiceNames.Count.Should().Be(names.Count, "ServiceNames"); target.ServiceNames.All(n => names.Contains(n.Name)).Should().BeTrue("Not all names are translated correctly"); var descriptions = conversion.GetValidTexts(step1.ShortDescriptions, step1.Description, step1.UserInstruction, step1.AdditionalInformation, step1.AdditionalInformationDeadLine, step1.AdditionalInformationProcessingTime, step1.AdditionalInformationValidityTime); target.ServiceDescriptions.Count.Should().Be(descriptions.Count, "ServiceDescriptions"); target.ServiceDescriptions.All(n => descriptions.Contains(n.Description)).Should().BeTrue("Not all description are translated correctly"); target.ServiceRequirements.Count.Should().Be(1, "ServiceRequirements"); target.ServiceLanguages.Count.Should().Be(step1.Languages.Count, "ServiceLanguages"); // target.ServiceCoverageTypeId.Should().Be(step1.ServiceCoverageTypeId); target.FundingTypeId.Should().Be(step1.FundingTypeId); }
// GET: ServiceDetails public ActionResult ServiceDetails(int Id) { VmService model = new VmService(); #region Wish list HttpCookie cookie = Request.Cookies["WishList"]; if (cookie != null) { List <string> WishList = cookie.Value.Split(',').ToList(); WishList.RemoveAt(WishList.Count - 1); ViewBag.WishList = WishList; ViewBag.WishListCount = WishList.Count; } else { ViewBag.WishListCount = 0; } #endregion #region Cart list HttpCookie cookieCart = Request.Cookies["Cart"]; List <string> CartList = new List <string>(); if (cookieCart != null) { CartList = cookieCart.Value.Split(',').ToList(); CartList.RemoveAt(CartList.Count - 1); ViewBag.CartList = CartList; ViewBag.CartListCount = CartList.Count; } else { ViewBag.CartListCount = 0; } #endregion model.Service = db.Services.Include("Appointments").FirstOrDefault(d => d.Id == Id); model.HeaderImage = db.HeaderImages.FirstOrDefault(h => h.Page == "ServiceDetails"); ViewBag.HomeSetting = db.HomeSettings .Include("HomeSocials") .Include("HomeSocials.SocialType").FirstOrDefault(); return(View(model)); }
public async Task Sync() { List <Vm> vms = new List <Vm>(); Microsoft.EntityFrameworkCore.Query.IIncludableQueryable <Adapter, Credentials> adapters = _context.Adapters.Where(x => x.IsOK).Include(x => x.Provider).Include(a => a.Credentials); foreach (Adapter adapter in adapters) { if (!adapter.IsOK) { break; } switch (adapter.Provider.Name.ToLower()) { case "ovirt": ServicesResponse servicesResponse = await VmService.GetFullVms(adapter); if (!servicesResponse.isSuccess) { break; } List <Vm> commonVMs = (List <Vm>)servicesResponse.resultObject; vms.AddRange(commonVMs); break; } } var oldVms = await _context.Vms.ToListAsync(); _context.Vms.RemoveRange(oldVms); vms.ConvertAll(x => x.LastTimeUpdated = DateTime.Now); _context.Vms.AddRange(vms); //foreach (var vm in vms) //{ // var entity = _context.Vms.Find(vm.Id); // if (entity == null) // { // _context.Vms.Add(vm); // } // else // { // _context.Entry(entity).CurrentValues.SetValues(vm); // } //} await _context.SaveChangesAsync(); }
protected virtual void OnApplyExecute() { if (_lastApplyCode == Code) { return; } _lastApplyCode = Code; Task.Run(async() => { if (await VmService.ApplyPromoCode(Code)) { Messenger.Publish(_updateMessage); } }); }
public async Task OnRgChanged(string value) { if (value != null) { Model.ResorceGroup = value; Model.VmName = null; Model.VmState = null; LastVmStatus = null; ShowLoading(); var vms = await VmService.GetVmNames(Model.SubcriptionId, Model.ResorceGroup); Vms = vms ?? new List <string>(); HideLoading(); } }
protected override Task ReloadContent() { return(Task.Run(async() => { if (Loading || Reloading) { return; } Reloading = true; var items = await VmService.LoadPoints(SearchText, 0, LOADING_COUNT); InvokeOnMainThread(() => Items = items); CanLoadMore = !items.IsNullOrEmpty() && items.Count == LOADING_COUNT; Reloading = false; })); }
public CatalogItemVM(Product model) { Model = model; Id = model.Id; if (!model.ImageUrls.IsNullOrEmpty()) { var image = model.ImageUrls.First(); ImageUrl = image.SmallUrl; } Name = model.Name; Price = model.Price; UnitName = model.UnitName; MaxPrice = model.MaxPrice; OldPrice = model.OldPrice; UnitNameOld = model.UnitNameOld; if (!model.Badges.IsNullOrEmpty()) { Badges = model.Badges.Select(SetupBadgeItem).ToList(); } Marked = model.IsMarked; StateName = model.State?.Name; MarkEnabled = ConfigService.Config.MarkedEnabled; BasketBlockViewModel = VmService.LoadItemBasketVm(); if (BasketBlockViewModel is IMvxViewModel <IMvxBundle> parameterVM) { parameterVM.Prepare(new ProductCardBundle(Model, Base.Core.Models.Navigation.NavigationType.InsideScreen)); } else { BasketBlockViewModel?.Init(new ProductCardBundle(Model, Base.Core.Models.Navigation.NavigationType.InsideScreen)); } }
public async Task <ActionResult <BackResponse> > UpdateVm(Vm vm) { var backResponse = new BackResponse(); if (!ModelState.IsValid) { backResponse.Status = "Model state no valid"; return(BadRequest(backResponse)); } if (vm?.Adapter == null) { backResponse.Status = "Vm adapter is null"; return(BadRequest(backResponse)); } Adapter adapter = await _context.Adapters.Where(x => x.IsOK) .Include(c => c.Credentials) .Include(p => p.Provider) .Where(a => a.Id == vm.Adapter.Id) .SingleOrDefaultAsync(); ServicesResponse servicesResponse; switch (adapter.Provider.Name.ToLower()) { case "ovirt": servicesResponse = await VmService.UpdateVm(adapter, vm); if (!servicesResponse.isSuccess) { backResponse.IsSuccess = false; backResponse.Status = servicesResponse.errorMessage; backResponse.StatusCode = servicesResponse.errorCode; } else { backResponse.IsSuccess = true; } break; } return(Ok(backResponse)); }
protected virtual async Task ProcessCardPayment(PaymentOrderInfo paymentInfo) { Loading = true; var paymentResult = await VmService.PayWithCard(CardNumber.Without(' '), ExpirationDate, Cvv, CardHolder, paymentInfo.Amount, paymentInfo.Currency, () => { Loading = false; }, OrderId); if (paymentResult.Succeeded) { await PaymentsVmService.OrderPaid(OrderId); } else { await UserDialogs.Error(paymentResult.ErrorMessage.IsNullOrEmtpy()? "Не удалось совершить платеж, проверьте введенные данные. Если ошибка повторится попробуйте совершить платеж позже" : paymentResult.ErrorMessage); } Loading = false; }