public void UpdateAccountProfile(AccountProfileViewModel model) { using (new SecurityDisabler()) { var editAccount = Master.GetItem(model.Id.ToString()); editAccount.Editing.BeginEdit(); try { editAccount.Fields["NameField"].Value = model.NameUVM; editAccount.Fields["SurnameField"].Value = model.SurnameUVM; editAccount.Fields["PhoneField"].Value = model.PhoneUVM; editAccount.Editing.EndEdit(); GlobalLogic.PublishItem(editAccount); } catch (Exception ex) { Sitecore.Diagnostics.Log.Error( "Could not update item " + editAccount.Paths.FullPath + ": " + ex.Message, this); editAccount.Editing.CancelEdit(); } } }
public void AddContactRev(string ContactName, string ContactSurname, string ContactPhone, string ContactCompany, string ContactMessage) { var emailName = User.Current.Name; using (new SecurityDisabler()) { var itemName = emailName.Split('\\')[1]; itemName = itemName.Replace("@", "__"); itemName = itemName.Replace('.', '_'); Item parent = Master.GetItem(ID.Parse("{9B751520-3D50-4A08-A437-B1576A3549BF}")); // id folder TemplateItem temp = Master.GetItem(ID.Parse("{693EFA96-9C09-4764-A5FD-E90F3EE9394D}")); // conatct // Add the item to the site tree var newItem = parent.Add(itemName, temp); // Set the new item in editing mode // Fields can only be updated when in editing mode // (It's like the begin tarnsaction on a database) newItem.Editing.BeginEdit(); try { // Assign values to the fields of the new item newItem.Fields["Name"].Value = ContactName; newItem.Fields["Surname"].Value = ContactSurname; newItem.Fields["Email"].Value = emailName; newItem.Fields["Phone"].Value = ContactPhone; newItem.Fields["Company"].Value = ContactCompany; newItem.Fields["Message"].Value = ContactMessage; // End editing will write the new values back to the Sitecore // database (It's like commit transaction of a database) newItem.Editing.EndEdit(); GlobalLogic.PublishItem(newItem); } catch (Exception ex) { // The update failed, write a message to the log Sitecore.Diagnostics.Log.Error( "Could not update item " + newItem.Paths.FullPath + ": " + ex.Message, this); //TODO $"" и вынести в константу // Cancel the edit (not really needed, as Sitecore automatically aborts // the transaction on exceptions, but it wont hurt your code) newItem.Editing.CancelEdit(); } } }
public void AddBikeAsOrder(string bikeId, string bikeName, string bikePrice) { var emailName = User.Current.Name; using (new SecurityDisabler()) { var itemName = emailName.Split('\\')[1]; itemName = itemName.Replace("@", "__"); itemName = itemName.Replace('.', '_'); Item parent = Master.GetItem(ID.Parse("{08D7057C-369D-4900-9FA0-4BCD976216D8}")); // id folder TemplateItem temp = Master.GetItem(ID.Parse("{510E2C3A-FAE7-4285-8737-537CFC4CDEA7}")); // bikeOrder // Add the item to the site tree var newItem = parent.Add(itemName, temp); // Set the new item in editing mode // Fields can only be updated when in editing mode // (It's like the begin tarnsaction on a database) newItem.Editing.BeginEdit(); try { // Assign values to the fields of the new item newItem.Fields["EmailName"].Value = emailName; newItem.Fields["BikeId"].Value = bikeId; newItem.Fields["BikeName"].Value = bikeName; newItem.Fields["Price"].Value = bikePrice; //newItem.Fields["Phone"].Value = // End editing will write the new values back to the Sitecore // database (It's like commit transaction of a database) newItem.Editing.EndEdit(); GlobalLogic.PublishItem(newItem); } catch (Exception ex) { // The update failed, write a message to the log Sitecore.Diagnostics.Log.Error( "Could not update item " + newItem.Paths.FullPath + ": " + ex.Message, this); //TODO $"" и вынести в константу // Cancel the edit (not really needed, as Sitecore automatically aborts // the transaction on exceptions, but it wont hurt your code) newItem.Editing.CancelEdit(); } } }
private void CreateUser(string email) { using (new SecurityDisabler()) { var itemName = email.Split('\\')[1]; itemName = itemName.Replace("@", "__"); itemName = itemName.Replace('.', '_'); Item parent = Master.GetItem(ID.Parse("{670F3170-CDF1-481F-A5F7-891248E364D0}")); // id folder TemplateItem temp = Master.GetItem(ID.Parse("{4D06567A-3CC1-49FA-81A5-19400E23F995}")); // account // Add the item to the site tree var newItem = parent.Add(itemName, temp); // Set the new item in editing mode // Fields can only be updated when in editing mode // (It's like the begin tarnsaction on a database) newItem.Editing.BeginEdit(); try { // Assign values to the fields of the new item newItem.Fields["EmailField"].Value = email; //newItem.Fields["Phone"].Value = // End editing will write the new values back to the Sitecore // database (It's like commit transaction of a database) newItem.Editing.EndEdit(); GlobalLogic.PublishItem(newItem); } catch (Exception ex) { // The update failed, write a message to the log Sitecore.Diagnostics.Log.Error( "Could not update item " + newItem.Paths.FullPath + ": " + ex.Message, this); //TODO $"" и вынести в константу // Cancel the edit (not really needed, as Sitecore automatically aborts // the transaction on exceptions, but it wont hurt your code) newItem.Editing.CancelEdit(); } } }