public JsonResult Create(LocalizationViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } var toCreate = new Models.LocalizationModel() { Key = model.Key, Value = model.Value, Culture = model.Culture, LastModDate = DateTime.Now, ModUser = User.Identity.Name, TranslationStatus = Enums.EnumTranslationStatus.Undefined, WasHit = false }; try { var dbobj = localizationRepository.Create(toCreate, User.Identity.Name); db.SaveChanges(); return(Json(new { Result = "OK", Record = dbobj.ToLocalizationViewModel() })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult Update(PredefinedMinerClientViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } try { var dbObj = db.PredefinedMinerClients.FirstOrDefault(ln => ln.Id == model.Id); if (dbObj == null) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidPredefMinerClientId") })); } if (db.PredefinedMinerClients.Any(ln => ln.ClientId == model.ClientId)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("PredefClientAlreadyExists") })); } dbObj.ClientId = model.ClientId; dbObj.ScriptUrl = model.ScriptUrl; db.SaveChanges(); return(Json(new { Result = "OK", Message = "data saved.." })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public static MvcHtmlString Get_SortSelector_Orders() { string res = @" <div class=\'ui-field-contain\'> <label for='sort-select-orders'>" + BaseResource.Get("SortSelect") + @" </label> <select name='sort-select-orders' id='sort-select-orders' multiple='multiple' data-native-menu='false'> <option>" + BaseResource.Get("SortSelectChoose") + @"</option> <option value='CreationDate ASC'>CreationDate ASC</option> <option value='CreationDate DSC'>CreationDate DSC</option> <option value='CustomerUser ASC'>CustomerUser ASC</option> <option value='CustomerUser DSC'>CustomerUser DSC</option> <option value='StoreUser ASC'>StoreUser ASC</option> <option value='StoreUser DSC'>StoreUser DSC</option> <option value='OrderState ASC'>OrderState ASC</option> <option value='OrderState DSC'>OrderState DSC</option> <option value='ShippingState ASC'>ShippingState ASC</option> <option value='ShippingState DSC'>ShippingState DSC</option> <option value='PaymentState ASC'>PaymentState ASC</option> <option value='PaymentState DSC'>PaymentState DSC</option> </select> </div>"; res += @"<script> $('#sort-select-orders').bind( 'change', function(event, ui) { OrdersSortSelectionChanged(event,ui); });</script>"; return(new MvcHtmlString(res)); }
public ActionResult Delete(int Id) { try { var dbObj = db.ServiceSettings.FirstOrDefault(ln => ln.ID == Id); if (!User.IsInRole("Admin")) { if (!Utils.ServiceUtils.IsServiceOwner(dbObj.ID, User.Identity.Name)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("NoPermission") })); } } db.StripeSettings.RemoveRange(dbObj.StripeSettings); db.ServiceSettings.Remove(dbObj); db.SaveChanges(); return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult RolesCreate(ViewModels.RoleViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } try { var rcreateres = _roleManager.Create(new IdentityRole() { Name = model.Name }); if (rcreateres.Succeeded) { var newrole = _roleManager.FindByName(model.Name); return(Json(new { Result = "OK", Record = new ViewModels.RoleViewModel() { Id = newrole.Id, Name = newrole.Name } })); } else { return(Json(new { Result = "ERROR", Message = rcreateres.Errors.First().ToString() })); } } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public static MvcHtmlString Get_FilterSelector_Products() { string res = @" <fieldset> <label for='filter-select-products'>" + BaseResource.Get("FilterSelect") + @"</label> <select name='filter-select-products' id='filter-select-products'> <option>" + BaseResource.Get("FilterSelectChoose") + @"</option> <option value='PartNumber'>PartNumber</option> <option value='ProductName'>ProductName</option> <option value='Description'>Description</option> <option value='Owner'>Owner</option> <option value='Price'>Price</option> </select> <label for='orderfilterinput'>" + BaseResource.Get("FilterInput") + @"</label> <input type='text' name='orderfilterinput' id='orderfilterinput'> "; res += @"<input type='button' class='ui-button ui-widget ui-corner-all' onclick='filtersearchbuttonclicked()' value='" + BaseResource.Get("BtnFilterSearch") + "'></input>"; res += "</fieldset>"; res += @"<script> $(function() { // $('#filter-select-products').selectmenu(); }); </script>"; return(new MvcHtmlString(res)); }
public JsonResult ProductImportStart(int importConfigId) { var user = userRepository.GetUser(User.Identity.Name); Utils.ProgressDialogUtils.Show("productImport", BaseResource.Get("ProductImportDialogTitle"), BaseResource.Get("ProductImportStarted"), 1, user.SignalRConnections); var config = db.ProductImportConfigurations.FirstOrDefault(ln => ln.Id == importConfigId); if (config == null) { Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("ImportConfigNotFound"), 0, user.SignalRConnections); return(Json(new { Success = false, Message = "config not found.." })); } if (!User.IsInRole("Admin") && config.Owner.ID != user.Id) { Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("ImportNotOwnerOfConfig"), 0, user.SignalRConnections); return(Json(new { Success = false, Message = "no permission to load this config..." })); } var importer = Factories.ProductImportFactory.GetProductImportImplementation(Enums.EnumImportType.GoogleProductXML); Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("Cleaning"), 0, user.SignalRConnections); var prodsToRemove = db.ProductTmpImport.Where(ln => ln.Owner.ID == user.Id).ToList(); db.ProductTmpImport.RemoveRange(prodsToRemove); //int rctr = 0; //foreach(var ritem in prodsToRemove) //{ // rctr++; // Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("CleaningItem") + " (" + rctr + " / " + toCleanCount + ")", Utils.ProductUtils.calc_percent(rctr, toCleanCount), user.SignalRConnections); // db.ProductTmpImport.Remove(ritem); //} db.SaveChanges(); if (importer.ImportSource(config.Source, config.Owner.ID, user.SignalRConnections)) { Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("MessageProductImportFinished"), 100, user.SignalRConnections); return(Json(new { Success = true, Message = "import completed.." })); } else { Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("MessageProductImportError"), 0, user.SignalRConnections); return(Json(new { Success = false, Message = "import failed.." })); } }
public JsonResult Update(LocalizationViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } try { var dbObj = localizationRepository.Update(model.ToLocalizationModel(), User.Identity.Name); Localization.UiResources.Instance.removeFromCache(dbObj.Key, CultureInfo.CurrentCulture.Name); return(Json(new { Result = "OK", Record = dbObj.ToLocalizationViewModel() })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult RolesUpdate(ViewModels.RoleViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } try { var role = _roleManager.FindById(model.Id); role.Name = model.Name; _roleManager.Update(role); return(Json(new { Result = "OK", Message = "data saved.." })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult User2RolesCreate(string IdentityName, string Roles) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } try { if (!_roleManager.RoleExists(Roles)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("Invalid Role...") })); } var role = _roleManager.Roles.FirstOrDefault(ln => ln.Name == Roles); var user = _userManager.FindByName(IdentityName); List <ViewModels.RoleViewModel> retlist = new List <ViewModels.RoleViewModel>(); var addRes = _userManager.AddToRole(user.Id, role.Name); if (addRes.Succeeded) { retlist.Add(new ViewModels.RoleViewModel() { Id = role.Id, Name = role.Name }); ViewModels.UserRolesViewModel ret = new ViewModels.UserRolesViewModel() { IdentityId = user.Id, IdentityName = user.UserName, Roles = retlist }; return(Json(new { Result = "OK", Record = ret })); } else { return(Json(new { Result = "ERROR", Message = addRes.Errors.First().ToString() })); } } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult Create(PredefinedMinerClientViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } if (string.IsNullOrWhiteSpace(model.ScriptUrl) || string.IsNullOrWhiteSpace(model.ClientId)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } try { if (db.PredefinedMinerClients.Any(ln => ln.Id == model.Id)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("PredefClientAlreadyExists") })); } var dbobj = db.PredefinedMinerClients.Add(new Models.PredefinedMinerClientModel() { ClientId = model.ClientId, ScriptUrl = model.ScriptUrl }); db.SaveChanges(); return(Json(new { Result = "OK", Record = dbobj.ToPreDefinedMinerClientViewModel() }, JsonRequestBehavior.AllowGet)); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { string msg = ""; foreach (var ve in ex.EntityValidationErrors) { msg += ve.ValidationErrors.FirstOrDefault().ErrorMessage; } return(Json(new { Result = "ERROR", Message = msg }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Create(ServiceSettingViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } if (!User.IsInRole("Admin")) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("NoPermission") })); } if (string.IsNullOrEmpty(model.ServiceUrl)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("URLCannotBeEmpty") })); } try { if (!Utils.ValidationUtils.IsNumbersAndLettersOnly(model.ServiceName) || !Utils.ValidationUtils.IsNumbersAndLettersOnly(model.ServiceUrl)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidDataOnlyNumbersAndLetters") })); } if (Utils.ValidationUtils.IsDangerousString(model.StripePublishableKey, out int dint) || Utils.ValidationUtils.IsDangerousString(model.StripeSecretKey, out dint)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidDataDangerousCharacters") })); } if (db.ServiceSettings.Any(ln => ln.ServiceUrl == model.ServiceUrl)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("ServiceUrlAlreadyTaken") })); } var userdata = db.UserData.FirstOrDefault(ln => ln.IdentityName == User.Identity.Name); if (userdata == null) { userdata = db.UserData.Add(new Models.UserDataModel() { IdentityName = User.Identity.Name }); } var dbobj = db.ServiceSettings.Add(new Models.ServiceSettingModel() { Owner = userdata, ServiceName = model.ServiceName, ServiceUrl = model.ServiceUrl, ServiceType = (Enums.EnumServiceType)model.ServiceType, }); switch (dbobj.ServiceType) { case Enums.EnumServiceType.OrderService: if (!string.IsNullOrEmpty(model.StripePublishableKey) && !string.IsNullOrEmpty(model.StripeSecretKey)) { dbobj.StripeSettings = new List <Models.StripeSettingsModel>(); dbobj.StripeSettings.Add(new Models.StripeSettingsModel() { PublishableKey = model.StripePublishableKey, SecretKey = model.StripeSecretKey }); } break; case Enums.EnumServiceType.TaxiService: break; case Enums.EnumServiceType.SecurityService: break; case Enums.EnumServiceType.OrderServiceDrone: break; case Enums.EnumServiceType.LuckyGameDefault: var defRule1 = new Models.LuckyGameWinningRule() { AmountMatchingCards = 3, WinFactor = 1.6f }; var defRule2 = new Models.LuckyGameWinningRule() { AmountMatchingCards = 4, WinFactor = 4 }; var defRule3 = new Models.LuckyGameWinningRule() { AmountMatchingCards = 5, WinFactor = 5 }; var defRule4 = new Models.LuckyGameWinningRule() { AmountMatchingCards = 6, WinFactor = 10 }; var gsmodel = new Models.LuckyGameSettingsModel() { MoneyAvailable = 0, WinningRules = new List <Models.LuckyGameWinningRule>() }; // gsmodel.WinningRules.Add(defRule0); gsmodel.WinningRules.Add(defRule1); gsmodel.WinningRules.Add(defRule2); gsmodel.WinningRules.Add(defRule3); gsmodel.WinningRules.Add(defRule4); dbobj.LuckyGameSettings = new List <Models.LuckyGameSettingsModel>(); dbobj.LuckyGameSettings.Add(gsmodel); break; case Enums.EnumServiceType.BaseTracking: break; case Enums.EnumServiceType.CrowdMinerCoinIMP: if (!string.IsNullOrEmpty(model.MinerClientId) && !string.IsNullOrEmpty(model.MinerScriptUrl)) { var defaultConfig = coinIMPMinerContext.GetDefaultMinerConfig(); dbobj.CoinIMPMinerConfiguration = new Models.CoinIMPMinerConfigurationModel() { ClientId = model.MinerClientId, ScriptUrl = model.MinerScriptUrl, Throttle = defaultConfig.Throttle, StartDelayMs = defaultConfig.StartDelayMs, ReportStatusIntervalMs = defaultConfig.ReportStatusIntervalMs }; } else { dbobj.CoinIMPMinerConfiguration = coinIMPMinerContext.GetDefaultMinerConfig(); } if (dbobj.MiningRooms == null) { dbobj.MiningRooms = new List <Models.MiningRoomModel>(); } dbobj.MiningRooms.Add(new Models.MiningRoomModel() { Name = model.ServiceName, Description = "-- -- --", ShowControls = true }); break; case Enums.EnumServiceType.DJRoom: if (dbobj.MiningRooms == null) { dbobj.MiningRooms = new List <Models.MiningRoomModel>(); } dbobj.MiningRooms.Add(new Models.MiningRoomModel() { Name = model.ServiceName, Description = "-- -- --", ShowControls = true }); break; case Enums.EnumServiceType.CrowdMinerJSECoin: var roomImplementation = Factories.MiningRoomFactory.GetImplementation(Enums.EnumMiningRoomType.JSECoin); /* todo: move following code in a CreateRoom interface-method */ if (!string.IsNullOrEmpty(model.MinerClientId) && !string.IsNullOrEmpty(model.MinerScriptUrl)) { var defaultConfig = jseCoinMinerContext.GetDefaultMinerConfig(); dbobj.JSECoinMinerConfiguration = new Models.JSECoinMinerConfigurationModel() { ClientId = defaultConfig.ClientId, SiteId = defaultConfig.SiteId, SubId = defaultConfig.SubId }; } else { dbobj.JSECoinMinerConfiguration = jseCoinMinerContext.GetDefaultMinerConfig(); } if (dbobj.MiningRooms == null) { dbobj.MiningRooms = new List <Models.MiningRoomModel>(); } dbobj.MiningRooms.Add(new Models.MiningRoomModel() { Name = model.ServiceName, Description = "-- -- --", ShowControls = true }); break; default: break; } db.SaveChanges(); return(Json(new { Result = "OK", Record = dbobj.ToServiceSettingViewModel() }, JsonRequestBehavior.AllowGet)); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { string msg = ""; foreach (var ve in ex.EntityValidationErrors) { msg += ve.ValidationErrors.FirstOrDefault().ErrorMessage; } return(Json(new { Result = "ERROR", Message = msg }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Update(ServiceSettingViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } if (!Utils.ValidationUtils.IsNumbersAndLettersOnly(model.ServiceName) || !Utils.ValidationUtils.IsNumbersAndLettersOnly(model.ServiceUrl)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidDataOnlyNumbersAndLetters") })); } if (Utils.ValidationUtils.IsDangerousString(model.StripePublishableKey, out int dint) || Utils.ValidationUtils.IsDangerousString(model.StripeSecretKey, out dint)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidDataDangerousCharacters") })); } try { var dbObj = db.ServiceSettings.FirstOrDefault(ln => ln.ID == model.Id); if (dbObj == null) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidSettingsId") })); } /* disable editing of url and type for non-admin */ if (!User.IsInRole("Admin")) { if (model.ServiceType != (int)Enums.EnumServiceType.CrowdMinerCoinIMP) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("ServiceTypeCannotBeChanged") })); } if (dbObj.ServiceUrl != model.ServiceUrl) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("ServiceUrlCannotBeChanged") })); } if (!Utils.ServiceUtils.IsServiceOwner(dbObj.ID, User.Identity.Name)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("NoPermission") })); } } if (db.ServiceSettings.Any(ln => ln.ServiceUrl == model.ServiceUrl && ln.ID != model.Id)) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("ServiceUrlAlreadyTaken") })); } dbObj.ServiceName = model.ServiceName; dbObj.ServiceType = (Enums.EnumServiceType)model.ServiceType; dbObj.ServiceUrl = model.ServiceUrl; if (dbObj.StripeSettings.Count == 0) { if (model.StripePublishableKey != string.Empty && model.StripePublishableKey != null && model.StripeSecretKey != string.Empty && model.StripeSecretKey != null ) { db.StripeSettings.Add(new Models.StripeSettingsModel() { PublishableKey = model.StripePublishableKey, SecretKey = model.StripeSecretKey, Service = dbObj }); } } else { if (model.StripePublishableKey != string.Empty && model.StripePublishableKey != string.Empty && model.StripeSecretKey != string.Empty) { dbObj.StripeSettings.First().PublishableKey = model.StripePublishableKey; dbObj.StripeSettings.First().SecretKey = model.StripeSecretKey; } else { db.StripeSettings.Remove(dbObj.StripeSettings.FirstOrDefault()); } } if (!string.IsNullOrEmpty(model.MinerClientId) && !string.IsNullOrEmpty(model.MinerScriptUrl)) { var defaultConfig = coinIMPMinerContext.GetDefaultMinerConfig(); dbObj.CoinIMPMinerConfiguration = new Models.CoinIMPMinerConfigurationModel() { ClientId = model.MinerClientId, ScriptUrl = model.MinerScriptUrl, Throttle = defaultConfig.Throttle, StartDelayMs = defaultConfig.StartDelayMs, ReportStatusIntervalMs = defaultConfig.ReportStatusIntervalMs }; } else { dbObj.CoinIMPMinerConfiguration = coinIMPMinerContext.GetDefaultMinerConfig(); } db.SaveChanges(); return(Json(new { Result = "OK", Message = "data saved.." })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public ActionResult Contact() { ViewBag.Message = BaseResource.Get("ContactPageTitle"); return(View()); }
public bool ImportSource(string src, int ownerId, List <string> connections) { try { var user = userRepository.GetUser(ownerId); var dbuser = userContext.GetUser(ownerId); var xe = XElement.Load(src); var items = xe.Elements("channel").Elements("item"); if (items.Count() == 0) { return(false); } int cntr = 0; int total = items.Count(); foreach (var item in items) { cntr++; Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("ProcessingItem") + " (" + cntr + " / " + total + ")", Utils.ProductUtils.calc_percent(cntr, total), connections); var pmodel = buildImportModel(item, dbuser); _db.ProductTmpImport.Add(pmodel); var existing = _db.Products.FirstOrDefault(ln => ln.SrcIdentifier == pmodel.SrcId && ln.Owner.ID == user.Id); if (existing == null) { _db.Products.Add(new Models.ProductModel() { Name = pmodel.Title, Description = pmodel.Description, ImageUrl = pmodel.ImageLink, Owner = dbuser, PartNo = pmodel.Mpn, Price = getPrice(pmodel.PriceString), SrcIdentifier = pmodel.SrcId, ProductIdentifier = Guid.NewGuid().ToString() }); } else { existing.Description = pmodel.Description; existing.ImageUrl = pmodel.ImageLink; existing.Name = pmodel.Title; existing.Owner = pmodel.Owner; existing.PartNo = pmodel.Mpn; existing.Price = getPrice(pmodel.PriceString); } } _db.SaveChanges(); Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("RecreatingLuceneIndex"), 100, user.SignalRConnections); Utils.LuceneUtils.AddUpdateLuceneIndex(_db.ProductTmpImport.Where(ln => ln.Owner.ID == user.Id)); Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("ProductImportFinished"), 100, user.SignalRConnections); return(true); } catch (Exception ex) { return(false); throw; } }
private Utils.LuckyGameCardResult getLuckyGameResultFor(int slotCount, string group, double amount) { var res = new Utils.LuckyGameCardResult(); res.Cards = new List <Utils.LuckyGameCard>(); if (amount < 1) { res.ErrorNumber = 667; res.Message = BaseResource.Get("AmountToLow"); } var user = userRepository.GetUserFromSignalR(Context.ConnectionId); var userTotal = userRepository.GetUserTotalMoney(user.Id); if (userTotal < amount) { res.ErrorNumber = 666; res.Message = BaseResource.Get("NotEnoughMoney"); return(res); } List <Utils.LuckyGameCard> reslist = new List <Utils.LuckyGameCard>(); for (int i = 0; i < slotCount; i++) { reslist.Add(Utils.LuckyGameUtils.GetRandomCard()); } var groups = reslist.OrderBy(x => x.Key).GroupBy(x => x.Key); var service = db.ServiceSettings.FirstOrDefault(ln => ln.ServiceUrl == group); if (service != null) { var gameSettings = service.LuckyGameSettings.FirstOrDefault(); if (gameSettings != null) { float winFactor = 0; foreach (var gitem in groups) { var matches = gitem.Count(); var rule = gameSettings.WinningRules.FirstOrDefault(ln => ln.AmountMatchingCards == matches); if (rule != null) { if (rule.WinFactor > winFactor) { winFactor = rule.WinFactor; } } } if (winFactor == 0) { //lost res.AmountLost = amount; res.UserTotalAmount = userRepository.WithdrawMoneyFromUser(user.Id, amount); res.TotalAmountAvailable = gameSettingsRepository.AddMoneyToGame(amount, group); } else { //won res.WinFactor = winFactor; res.AmountWon = amount * winFactor; res.TotalAmountAvailable = gameSettingsRepository.WidthdrawMoneyFromGame(amount, group); res.UserTotalAmount = userRepository.DepositMoneyToUser(user.Id, amount); } } else { res.ErrorNumber = 231; res.Message = "No gameSettings..."; } } res.Cards = reslist; return(res); }
private ViewModels.OrderViewModel _processOrderRequest(OrderDataDTO orderDTO, string group) { IOrderProcess orderProcessFactory = null; if (Utils.ValidationUtils.IsDangerousString(orderDTO.OrderIdentifier, out int badidx)) { return new ViewModels.OrderViewModel() { ErrorMessage = "Invalid orderIdentifier" } } ; var orderViewModel = orderRepository.GetOrder(orderDTO.OrderIdentifier); var service = db.ServiceSettings.FirstOrDefault(ln => ln.ServiceUrl == group); if (service == null) { return new ViewModels.OrderViewModel() { ErrorMessage = "could not get service..." } } ; orderProcessFactory = Factories.OrderProcessFactory.GetOrderProcessImplementation(service.ServiceType); if (orderViewModel == null) { if (orderDTO.Items.Count == 0) { return new ViewModels.OrderViewModel() { ErrorMessage = BaseResource.Get("NoItemsForOrder") } } ; orderViewModel = orderProcessFactory.CheckOrder(orderDTO); if (!string.IsNullOrEmpty(orderViewModel.ErrorMessage)) { return(orderViewModel); } var orderItems = orderRepository.CheckProducts(orderDTO.Items); var productOwnerId = orderItems.FirstOrDefault().OwnerId; // --! var storeUser = userRepository.GetUser(productOwnerId); var customerUser = userRepository.GetUserFromSignalR(Context.ConnectionId); if (storeUser == null || customerUser == null || productOwnerId == -1 || orderItems.Count == 0) { return(new ViewModels.OrderViewModel() { ErrorMessage = "Invalid Order-Data...", }); } orderViewModel.Items = orderItems; orderViewModel.CustomerUser = customerUser; orderViewModel.StoreUser = storeUser; } bool isStoreUser = false; if (Context.User.Identity.Name == orderViewModel.StoreUser.Name) { isStoreUser = true; } orderProcessFactory = Factories.OrderProcessFactory.GetOrderProcessImplementation(Enums.EnumServiceType.OrderService); var orderVMResult = orderProcessFactory.ProcessOrder(orderViewModel, isStoreUser); orderViewModel = orderVMResult; return(orderViewModel); }