예제 #1
0
파일: OrderSVC.cs 프로젝트: gkovalev/nastia
    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);
    }
예제 #2
0
파일: OrderSVC.cs 프로젝트: gkovalev/nastia
    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);
        }
    }
예제 #3
0
    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);
    }
예제 #4
0
파일: OrderSVC.cs 프로젝트: gkovalev/nastia
    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);
        }
    }
예제 #5
0
 public Customer GetCustomer(string customerId)
 {
     if (!AuthorizeService.CheckAdminCookies())
     {
         return(null);
     }
     return(CustomerService.GetCustomer(customerId.TryParseGuid()));
 }
예제 #6
0
 public List <Customer> GetCustomers()
 {
     if (!AuthorizeService.CheckAdminCookies())
     {
         return(null);
     }
     return(new List <Customer>(CustomerService.GetCustomers()));
 }
예제 #7
0
 public CustomerContact GetCustomerContact(string contactId)
 {
     if (!AuthorizeService.CheckAdminCookies())
     {
         return(null);
     }
     return(CustomerService.GetCustomerContact(contactId));
 }
예제 #8
0
 public List <CustomerContact> GetCustomerContacts(string customerId)
 {
     if (!AuthorizeService.CheckAdminCookies())
     {
         return(null);
     }
     return(CustomerService.GetCustomerContacts(customerId.TryParseGuid()));
 }
예제 #9
0
 public string AddProduct(Product product)
 {
     if (!AuthorizeService.CheckAdminCookies())
     {
         return(MsgAuthFailed);
     }
     return(ProductService.AddProduct(product, true) != 0 ? string.Format(MsgAddSuccess, product.ProductId) : MsgAddError);
 }
예제 #10
0
 public Product GetProductBy(string artNo)
 {
     if (!AuthorizeService.CheckAdminCookies())
     {
         return(new Product());
     }
     return(ProductService.GetProduct(artNo));
     //Return GetProduct(ArtNo, True)
 }
예제 #11
0
 public Product GetProductBy(int id)
 {
     if (!AuthorizeService.CheckAdminCookies())
     {
         return(null);
     }
     return(ProductService.GetProduct(id));
     //Return GetProduct(id, False)
 }
예제 #12
0
    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));
    }
예제 #13
0
    public Products GetProductsByCategoryID(int catId)
    {
        if (!AuthorizeService.CheckAdminCookies())
        {
            return(null);
        }
        var products = new Products();

        products.AddRange(CategoryService.GetProductsByCategoryId(catId));
        return(products);
    }
예제 #14
0
    public Products GetProducts()
    {
        if (!AuthorizeService.CheckAdminCookies())
        {
            return(null);
        }
        var products = new Products();

        products.AddRange(ProductService.GetProducts());

        return(products);
    }
예제 #15
0
    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));
    }
예제 #16
0
    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));
    }
예제 #17
0
    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));
    }
예제 #18
0
    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));
    }
예제 #19
0
    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));
    }
예제 #20
0
 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));
 }
예제 #21
0
    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));
    }
예제 #22
0
    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);
    }
예제 #23
0
    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));
    }
예제 #24
0
 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));
 }
예제 #25
0
    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);
    }
예제 #26
0
    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);
    }
예제 #27
0
    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);
        }
    }
예제 #28
0
    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));
    }
예제 #29
0
    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));
    }
예제 #30
0
파일: OrderSVC.cs 프로젝트: gkovalev/nastia
    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);
        }
    }