/// <summary> /// Creates the user and profile. /// </summary> /// <param name="user">The user.</param> /// <returns></returns> public static string CreateUserAndProfile(UserDetails user) { if (user.IsValid) { //save profile details too ProfileCommon p = new ProfileCommon(); ProfileCommon newProfile = p.GetProfile(user.UserName); newProfile.WarehouseId = user.WarehouseId; newProfile.RegionId = user.RegionId; newProfile.OpCoId = user.OpCoId; newProfile.SalesLocationId = user.SalesLocationId; newProfile.OpCoCode = ""; newProfile.RegionCode = ""; if (user.OpCoId != -1) { newProfile.OpCoCode = OpcoController.GetOpCo(user.OpCoId, false).Code; } if (user.RegionId != -1) { newProfile.RegionCode = OptrakRegionController.GetRegion(user.RegionId).Code; } newProfile.Save(); Membership.CreateUser(user.UserName, user.NewPassword, user.Email); return(user.UserName); } return(""); }
/// <summary> /// Initializes a new instance of the <see cref="T:UserDetails"/> class. /// </summary> /// <param name="membershipUser">The membership user.</param> /// <param name="getProfile">if set to <c>true</c> [get profile].</param> public UserDetails(MembershipUser membershipUser, bool getProfile) { if (membershipUser != null) { UserName = membershipUser.UserName; Email = membershipUser.Email; LastActivityDate = membershipUser.LastActivityDate.ToShortDateString(); if (getProfile) { ProfileCommon p = new ProfileCommon(); ProfileCommon profile = p.GetProfile(membershipUser.UserName); if (profile != null) { OpCoId = profile.OpCoId; OpCoCode = profile.OpCoCode; RegionId = profile.RegionId; RegionCode = profile.RegionCode; WarehouseId = profile.WarehouseId; SalesLocationId = profile.SalesLocationId; SalesLocation = SalesLocationController.GetLocation(salesLocationId, false); OpCo = OpcoController.GetOpCo(OpCoId, false); Warehouse = WarehouseController.GetWarehouse(WarehouseId); Region = OptrakRegionController.GetRegion(RegionId); } } } }
/// <summary> /// Processes the request. /// </summary> /// <param name="requestMessage">The request message.</param> public override void ProcessRequest(RequestMessage requestMessage) { Trip.SetTripSchema(textFieldParser.TextFields); //get all warehouse objects in one hit for performance allWarehouses = WarehouseController.GetWarehouses(false); //get all regions in one hit for performance allRegions = OptrakRegionController.GetRegions(); try { textFieldParser.FirstLineIsHeader = true; textFieldParser.FileType = TextFieldParser.FileFormat.Delimited; textFieldParser.Delimiter = '|'; textFieldParser.TrimWhiteSpace = true; // Set up event handlers for when a row is read and when a row is read but failes to match the expected schema textFieldParser.RecordFound += new TextFieldParser.RecordFoundHandler(textParser_RecordFound); textFieldParser.RecordFailed += new TextFieldParser.RecordFailedHandler(RecordFailed); // parse the message textFieldParser.ParseFileContents(requestMessage.Body); // Processed Status = SaveTrips(); } catch (Exception ex) { // Store the exception LastError = ex; // Failed Status = SubscriberStatusEnum.Failed; } }
/// <summary> /// Updates the user and profile. /// </summary> /// <param name="user">The user.</param> public static string UpdateUserAndProfile(UserDetails user) { if (user.IsValid) { MembershipUser membershipUser = Membership.GetUser(user.UserName); membershipUser.Email = user.Email; bool success = true; if (!string.IsNullOrEmpty(user.OldPassword) && !string.IsNullOrEmpty(user.NewPassword)) { success = membershipUser.ChangePassword(user.OldPassword, user.NewPassword); } if (success) { Membership.UpdateUser(membershipUser); //update profile too ProfileCommon p = new ProfileCommon(); ProfileCommon selectedProfile = p.GetProfile(user.UserName); selectedProfile.WarehouseId = user.WarehouseId; selectedProfile.RegionId = user.RegionId; selectedProfile.SalesLocationId = user.SalesLocationId; selectedProfile.OpCoId = user.OpCoId; selectedProfile.OpCoCode = ""; selectedProfile.RegionCode = ""; if (user.OpCoId != -1) { selectedProfile.OpCoCode = OpcoController.GetOpCo(user.OpCoId, false).Code; } if (user.RegionId != -1) { selectedProfile.RegionCode = OptrakRegionController.GetRegion(user.RegionId).Code; } selectedProfile.Save(); return(user.UserName); } else { throw new SystemException("The Password has not be successfully changed."); } } return(""); }
private void PopulateRegions() { // Get the region drop down DropDownList dropDownListRegion = GetControl <DropDownList>("ddlRegion", PageFormView); DropDownList dropDownListWarehouse = GetControl <DropDownList>("ddlWarehouse", PageFormView); // Populate the list of regions dropDownListRegion.DataSource = OptrakRegionController.GetRegions(); dropDownListRegion.DataBind(); // Now add the all dropDownListRegion.Items.Insert(0, new ListItem("All", "-1")); dropDownListWarehouse.Items.Insert(0, new ListItem("All", "-1")); // Now disable the warehouse dropDownListWarehouse.Items[0].Selected = true; dropDownListWarehouse.Enabled = false; }
public void GetItems() { using (TransactionScope scope = new TransactionScope()) { //add a region int id = OptrakRegionController.SaveRegion(PopulateNewItem()); if (id > -1) { //retrieve all regions and the one we saved should return at least List <OptrakRegion> regions = OptrakRegionController.GetRegions(); //so the count should be >0 Assert.IsTrue(regions.Count > 0); //check for our new id Assert.IsTrue(regions.Find(delegate(OptrakRegion currentItem) { return(currentItem.Id == id); }) != null); } } }
internal OptrakRegion GetItem(int id) { return(OptrakRegionController.GetRegion(id)); }
internal int SaveItem(OptrakRegion optrakRegion) { return(OptrakRegionController.SaveRegion(optrakRegion)); }
internal bool DeleteItem(OptrakRegion optrakRegion) { return(OptrakRegionController.DeleteRegion(optrakRegion)); }