public XmlDocument GetOrderStatuses() { if (!AuthorizeService.CheckAdminCookies()) { return(ErrMsg(MsgAuthFailed)); } var result = new XmlDocument(); XmlElement root = result.CreateElement("Statuses"); Dictionary <string, string> stats = OrderService.GetOrderStatuses(false); if (stats == null) { return(ErrMsg(MsgStatusesError)); } foreach (var stat in stats) { XmlElement status = result.CreateElement("Status"); XmlAttribute index = result.CreateAttribute("ID"); index.Value = stat.Key; status.Attributes.Append(index); status.InnerText = stat.Value; root.AppendChild(status); } result.AppendChild(root); return(result); }
public XmlDocument ExportOrderToXmlByStatusName(string statusName) { if (!AuthorizeService.CheckAdminCookies()) { return(ErrMsg(MsgAuthFailed)); } Dictionary <string, string> stats = OrderService.GetOrderStatuses(true); if (!stats.ContainsKey(statusName)) { return(ErrMsg(string.Format(MsgStatusError, statusName))); } List <Order> orders = OrderService.GetOrdersByStatusId(Int32.Parse(stats[statusName])); if (orders == null) { return(ErrMsg(MsgListError)); } using (var writer = new StringWriter()) { OrderService.SerializeToXml(orders, writer); var xml = new XmlDocument(); xml.Load(writer.ToString()); return(xml); } }
public string AddCategoryByFields(string name, int parent, string picture, bool enabled, int sortOrder) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } if (string.IsNullOrEmpty(picture)) { picture = null; } var category = new Category { Name = name, ParentCategoryId = parent, Picture = new Photo(0, 0, PhotoType.CategoryBig) { OriginName = picture }, SortOrder = sortOrder, Enabled = enabled }; int catId = CategoryService.AddCategory(category, true); return(catId != 0 ? string.Format(MsgAdded, catId) : MsgAddFailed); }
public XmlDocument ExportOrderToXmlByStatus(int statusId) { if (!AuthorizeService.CheckAdminCookies()) { return(ErrMsg(MsgAuthFailed)); } var stats = OrderService.GetOrderStatuses(false); if (!stats.ContainsKey(statusId.ToString())) { return(ErrMsg(string.Format(MsgStatusError, statusId))); } var orders = OrderService.GetOrdersByStatusId(statusId); if (orders == null) { return(ErrMsg(MsgListError)); } using (var writer = new StringWriter()) { OrderService.SerializeToXml(orders, writer); var xml = new XmlDocument(); xml.Load(writer.ToString()); return(xml); } }
public Customer GetCustomer(string customerId) { if (!AuthorizeService.CheckAdminCookies()) { return(null); } return(CustomerService.GetCustomer(customerId.TryParseGuid())); }
public List <Customer> GetCustomers() { if (!AuthorizeService.CheckAdminCookies()) { return(null); } return(new List <Customer>(CustomerService.GetCustomers())); }
public CustomerContact GetCustomerContact(string contactId) { if (!AuthorizeService.CheckAdminCookies()) { return(null); } return(CustomerService.GetCustomerContact(contactId)); }
public List <CustomerContact> GetCustomerContacts(string customerId) { if (!AuthorizeService.CheckAdminCookies()) { return(null); } return(CustomerService.GetCustomerContacts(customerId.TryParseGuid())); }
public string AddProduct(Product product) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } return(ProductService.AddProduct(product, true) != 0 ? string.Format(MsgAddSuccess, product.ProductId) : MsgAddError); }
public Product GetProductBy(string artNo) { if (!AuthorizeService.CheckAdminCookies()) { return(new Product()); } return(ProductService.GetProduct(artNo)); //Return GetProduct(ArtNo, True) }
public Product GetProductBy(int id) { if (!AuthorizeService.CheckAdminCookies()) { return(null); } return(ProductService.GetProduct(id)); //Return GetProduct(id, False) }
public string AddCustomer(Customer customer, string login, string password) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } Guid customerID = CustomerService.InsertNewCustomer(customer); return(string.Format(!customerID.Equals(Guid.Empty) ? MsgAddCustomerSuccess : MsgAddCustomerFailed, customerID)); }
public Products GetProductsByCategoryID(int catId) { if (!AuthorizeService.CheckAdminCookies()) { return(null); } var products = new Products(); products.AddRange(CategoryService.GetProductsByCategoryId(catId)); return(products); }
public Products GetProducts() { if (!AuthorizeService.CheckAdminCookies()) { return(null); } var products = new Products(); products.AddRange(ProductService.GetProducts()); return(products); }
public string DeleteCustomer(string customerId) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } int errCode = CustomerService.DeleteCustomer(Guid.Parse(customerId)); return(errCode == 0 ? string.Format(MsgDeleteCustomerSuccess, customerId) : string.Format(MsgDeleteCustomerFailed, customerId, errCode)); }
public string DeleteContact(Guid contactId) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } int errCode = CustomerService.DeleteContact(contactId); return(errCode == 0 ? string.Format(MsgDeleteContactSuccess, contactId) : string.Format(MsgDeleteContactFailed, contactId, errCode)); }
public string UpdateCustomer(Customer customer) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } int errCode = CustomerService.UpdateCustomer(customer); return(errCode == 0 ? string.Format(MsgUpdateCustomerSuccess, customer.Id) : string.Format(MsgUpdateCustomerFailed, customer.Id, errCode)); }
public string UpdateContact(CustomerContact contact) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } int errCode = CustomerService.UpdateContact(contact); return(errCode == 0 ? string.Format(MsgUpdateContactSuccess, contact.CustomerContactID) : string.Format(MsgUpdateContactFailed, contact.CustomerContactID, errCode)); }
public string AddContact(CustomerContact contact, string customerId) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } Guid errCode = CustomerService.AddContact(contact, new Guid(customerId)); return(errCode != Guid.Empty ? string.Format(MsgAddContactSuccess, contact.CustomerContactID) : string.Format(MsgAddContactFailed, contact.CustomerContactID, errCode)); }
public string DeleteCategory(int id) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } if (CategoryService.GetCategory(id) == null) { return(string.Format(MsgNotFound, id)); } CategoryService.DeleteCategoryAndPhotos(id); return(string.Format(CategoryService.GetCategory(id) == null ? MsgDeleted : MsgDeleteFailed, id)); }
public string UpdateCategory(Category category) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } if (category == null) { return(string.Format(MsgNotFound)); } var res = CategoryService.UpdateCategory(category, false); return(string.Format(res ? MsgUpdated : MsgUpdateFailed, category.CategoryId)); }
public XmlDocument GetCategory(int id) { if (!AuthorizeService.CheckAdminCookies()) { return(ErrMsg(MsgAuthFailed)); } XmlDocument result = CategoryService.ConvertToXml(id); if (result == null) { return(ErrMsg(string.Format(MsgNotFound, id))); } return(result); }
public string UpdateProductMeta(int productID, MetaInfo meta) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } Product p = ProductService.GetProduct(productID); if (p == null) { return(string.Format(MsgNotFound, productID)); } p.Meta = meta; MetaInfoService.SetMeta(p.Meta); return(string.Format(MsgUpdateSuccess, productID)); }
public string DeleteProduct(int id) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } if (ProductService.GetProduct(id) == null) { return(string.Format(MsgNotFound, id)); } if (ProductService.DeleteProduct(id, false)) { return(string.Format(MsgDeleteError, id)); } return(string.Format(MsgDeleteSuccess, id)); }
public XmlDocument GetChildCategiries(int parentId) { if (!AuthorizeService.CheckAdminCookies()) { return(ErrMsg(MsgAuthFailed)); } var result = new XmlDocument(); var root = (XmlElement)result.AppendChild(result.CreateElement("Categories")); var cats = (List <Category>)CategoryService.GetChildCategoriesByCategoryId(parentId, true); foreach (Category cat in cats) { root.InnerXml = root.InnerXml + CategoryService.ConvertToXml(cat).InnerXml; } return(result); }
public XmlDocument GetCategories() { if (!AuthorizeService.CheckAdminCookies()) { return(ErrMsg(MsgAuthFailed)); } var result = new XmlDocument(); XmlNode root = result.AppendChild(result.CreateElement("Categories")); IEnumerable <Category> categories = CategoryService.GetCategories(); foreach (Category cat in categories) { root.InnerXml = root.InnerXml + GetCategory(cat.CategoryId).InnerXml; } return(result); }
public string AddCategory(Category category) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } int catId = CategoryService.AddCategory(category, true); if (catId != 0) { return(string.Format(MsgAdded, catId)); } else { return(MsgAddFailed); } }
public string UpdateProduct(Product product) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } if (ProductService.IsExists(product.ProductId)) { return(string.Format(MsgNotFound, product.ProductId)); } if (ProductService.UpdateProduct(product, true)) { return(string.Format(MsgUpdateSuccess, product.ProductId)); } return(string.Format(MsgUpdateError, product.ProductId)); }
public string UpdateProductOffers(int productID, Offers offers) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } if (ProductService.IsExists(productID)) { return(string.Format(MsgNotFound, productID)); } OfferService.UpdateOffersByProductId(productID, offers); return(string.Format(MsgUpdateSuccess, productID)); return(string.Format(MsgUpdateError, productID)); }
public XmlDocument ExportOrderToXml(int orderId) { if (!AuthorizeService.CheckAdminCookies()) { return(ErrMsg(string.Format(MsgNotFound, orderId))); } Order order = OrderService.GetOrder(orderId); if (order == null) { return(ErrMsg(MsgListError)); } using (var writer = new StringWriter()) { OrderService.SerializeToXml(order, writer); var xml = new XmlDocument(); xml.Load(writer.ToString()); return(xml); } }