public ControlObjectException(EnumSeverity severity, EnumMessageCode messageCode) { UserMessage message = new UserMessage(); message.MessageCode = messageCode; message.Severity = severity; this._errorList.Add(message); }
public bool SaveSniper() { try { Snipe snipe = null; if (string.IsNullOrEmpty(this._view.snipeID)) { snipe = new Snipe(); snipe.SnipeStatus = EnumSnipeStatus.ACTIVE; snipe.SnipeType = EnumSnipeType.ONLINE; } else snipe = this._view.serviceUser.GetSnipe(int.Parse(this._view.snipeID)); try { #warning We consider that the separator is , snipe.SnipeBid = double.Parse(this._view.snipeBid.Replace('.',',')); } catch { // Will be handled in the SL_User function } snipe.ItemID = long.Parse(this._view.itemID); if (this._view.serviceUser.UserLoggedIn.ShowSnipeStyles) snipe.SnipeStyle = this._view.SnipeStyle; else snipe.SnipeStyle = EnumSnipeStyle.Manual; snipe.SnipeCategories = this._view.serviceUser.GetCategories(this._view.categoriesSelectedID); snipe.SnipeBidCurrency = this._view.serviceUser.UserLoggedIn.UserCurrency; //snipe.SnipeDelay = int.Parse(this._view.snipeDelay); snipe.SnipeDescription = this._view.snipeDescription; snipe.SnipeName = this._view.snipeName; if (this._view.snipeGenNextSnipe && this._view.serviceUser.isGenNextSnipeActive()) { snipe.SnipeGenNextSnipe = true; try { snipe.SnipeGenIncreaseBid = int.Parse(this._view.SnipeGenIncreaseBid); } catch { UserMessage message = new UserMessage(); message.MessageCode = EnumMessageCode.SnipeWrongGenIncreaseBid; List<UserMessage> errorList = new List<UserMessage>(); errorList.Add(message); ControlObjectException ex = new ControlObjectException(errorList); throw ex; } try { snipe.SnipeGenRemainingNb = int.Parse(this._view.SnipeGenRemainingNb); } catch { UserMessage message = new UserMessage(); message.MessageCode = EnumMessageCode.SnipeWrongGenRemainingNb; List<UserMessage> errorList = new List<UserMessage>(); errorList.Add(message); ControlObjectException ex = new ControlObjectException(errorList); throw ex; } } else { snipe.SnipeGenNextSnipe = false; snipe.SnipeGenIncreaseBid = 0; snipe.SnipeGenRemainingNb = null; } snipe.UserID = (int)this._view.serviceUser.UserLoggedIn.UserID; if (string.IsNullOrEmpty(this._view.snipeID)) { this._view.serviceUser.SnipeCreate(snipe); this._view.AddInformation("SnipeCreated", true, EnumSeverity.Information); this._navigation.ReloadPage("created=1"); } else { this._view.serviceUser.SnipeUpdate(snipe); this._view.AddInformation("SnipeUpdated", true, EnumSeverity.Information); this.EditSniper(false); this.LoadSniper(snipe); } return true; } catch (ControlObjectException ex) { foreach (UserMessage error in ex.ErrorList) this._view.AddInformation(error.MessageCode.ToString(), true, error.Severity); } catch (Exception ex) { this._view.AddInformation(ex.Message + ex.StackTrace, false, EnumSeverity.Bug); } return false; }