public void Save(Category category) { try { bool newcat = category.CategoryID == null; category.UserID = this._view.serviceUser.UserLoggedIn.UserID; this._view.serviceUser.CategorySave(category); this.LoadCategories(); this._view.ClearView(); if (newcat) this._view.AddInformation("CategoryCreated", true, EnumSeverity.Information); else this._view.AddInformation("CategoryUpdated", true, EnumSeverity.Information); } 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, false, EnumSeverity.Bug); } }
public void Delete(Category category) { try { this._view.serviceUser.DeleteCategory(category); this.LoadCategories(); this._view.ClearView(); this._view.AddInformation("CategoryDeleted", true, EnumSeverity.Information); } 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, false, EnumSeverity.Bug); } }
/// <summary> /// Save the category set as parameter /// </summary> /// <param name="category"></param> public void CategorySave(Category category) { if (!this._isUserLoggedIn) throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.UserNotLoggedIn); int nbCat = 0; bool found = false; Category catToBeSaved = null; foreach (Category cat in this.UserLoggedIn.UserCategoryList) { if (cat.IsCategoryActive) nbCat++; if (category.CategoryID != null && cat.CategoryID == category.CategoryID) { cat.CategoryName = category.CategoryName; catToBeSaved = cat; found = true; } } if (category.CategoryID != null) { if (found) this._myDataConnection.Save<Category>((object)catToBeSaved, catToBeSaved); else throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.CategoryIDNotFound); } else { if (nbCat >= 10) throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.CategoryMaxNumberReached); Category newCat = (Category)this._myDataConnection.Add<Category>((object)category, category); this.UserLoggedIn.UserCategoryList.Add(newCat); } }
protected void btnUpdate_Click(object sender, EventArgs e) { Category category = new Category(); category.IsCategoryActive = true; category.CategoryName = this.txtBxName.Text; if (string.IsNullOrEmpty(this.lblCategoryID.Text)) category.CategoryID = null; else category.CategoryID = int.Parse(this.lblCategoryID.Text); this.presenter.Save(category); }
protected void btnDelete_Click(object sender, EventArgs e) { Category category = new Category(); category.CategoryName = this.txtBxName.Text; category.CategoryID = int.Parse(this.lblCategoryID.Text); this.presenter.Delete(category); }
public void DeleteCategory(Category category) { Initialisation(); userHandler.DeleteCategory(category); }
public void CategorySave(Category category) { Initialisation(); userHandler.CategorySave(category); }
/// <summary> /// Create the user passed as parameter in the DB /// </summary> /// <param name="user">User to be created</param> /// <returns></returns> public User UserCreate(User user) { user.UserRegistrationDate = ServiceTimeZone.DateTimeToUniversal(DateTime.Now); user.UserOptionsEndDate = user.UserRegistrationDate.AddMonths(UserSettings.Default.UserOptionsFreeNbMonths); this._serviceEBay.User = user; user = (User)this._myDataConnection.Add<User>((object)user, user); Category category = new Category(); category.CategoryName = "Cat Num1"; category.IsCategoryActive = true; category.UserID = user.UserID; this._myDataConnection.Add<Category>((object)category, category); category = new Category(); category.CategoryName = "Cat Num2"; category.IsCategoryActive = true; category.UserID = user.UserID; this._myDataConnection.Add<Category>((object)category, category); category = new Category(); category.CategoryName = "Cat Num3"; category.IsCategoryActive = true; category.UserID = user.UserID; this._myDataConnection.Add<Category>((object)category, category); ServiceEmail.SendEmail(user, "[SnipeAgent] Welcome", "Hello, thanks for registering on www.snipeagent.com."); this._userLoggedIn = user; this._isUserLoggedIn = true; return user; }
/// <summary> /// Disable the category set as parameter /// </summary> /// <param name="category"></param> public void DeleteCategory(Category category) { Category cat = null; foreach (Category currentCat in this.UserLoggedIn.UserCategoryList) { if (currentCat.CategoryID == category.CategoryID) { currentCat.IsCategoryActive = false; currentCat.CategoryDisactivationDate = ServiceTimeZone.DateTimeToUniversal(DateTime.Now); cat = currentCat; break; } } this._myDataConnection.Delete<Category>((object)cat, cat); }