// // GET: /EDC/Category/Detail public async Task <ActionResult> Detail(string key) { using (CategoryServiceClient client = new CategoryServiceClient()) { MethodReturnResult <Category> result = await client.GetAsync(key); if (result.Code == 0) { CategoryViewModel viewModel = new CategoryViewModel() { Name = result.Data.Key, Status = result.Data.Status, CreateTime = result.Data.CreateTime, Creator = result.Data.Creator, Description = result.Data.Description, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { ModelState.AddModelError("", result.Message); } } return(PartialView("_InfoPartial")); }
private void add_Click(object sender, RoutedEventArgs e) { ServiceReference4.Category c = new ServiceReference4.Category(); CategoryServiceClient client = new CategoryServiceClient(); client.Add(c); }
/// <summary> /// Attempts to update the specified category. Prints results to console. /// </summary> /// <param name="id">The ID of the category to update</param> /// <param name="name">The new name</param> /// <param name="description">The new description</param> private static void TestUpdateCategory(int id, string name, string description) { var catService = new CategoryServiceClient(); try { Console.WriteLine(string.Format("\nAttempting to update category {0}.", id)); if (name == null) { Console.WriteLine(string.Format(" - Name = null.")); } if (description == null) { Console.WriteLine(string.Format(" - Description = null.")); } var cat = new Category { ID = id, Name = name, Description = description }; catService.UpdateCategory(cat); Console.WriteLine(string.Format(" - Category Updated: ID = {0}, Name = {1}, Description = {2}", cat.ID, cat.Name, cat.Description)); } catch (FaultException<CategoryFault> ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Detail.FaultMessage)); } catch (FaultException ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Message)); } }
public async Task <ActionResult> Query(CategoryQueryViewModel model) { if (ModelState.IsValid) { using (CategoryServiceClient client = new CategoryServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Key LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Name); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <Category> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
/// <summary> /// Attempts to update the specified category. Prints results to console. /// </summary> /// <param name="id">The ID of the category to update</param> /// <param name="name">The new name</param> /// <param name="description">The new description</param> private static void TestUpdateCategory(int id, string name, string description) { var catService = new CategoryServiceClient(); try { Console.WriteLine(string.Format("\nAttempting to update category {0}.", id)); if (name == null) { Console.WriteLine(string.Format(" - Name = null.")); } if (description == null) { Console.WriteLine(string.Format(" - Description = null.")); } var cat = new Category { ID = id, Name = name, Description = description }; catService.UpdateCategory(cat); Console.WriteLine(string.Format(" - Category Updated: ID = {0}, Name = {1}, Description = {2}", cat.ID, cat.Name, cat.Description)); } catch (FaultException <CategoryFault> ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Detail.FaultMessage)); } catch (FaultException ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Message)); } }
static void Main(string[] args) { CategoryServiceClient client = new CategoryServiceClient("BasicHttpBinding_ICategoryService"); bool service = true; Console.WriteLine("======== Welcome to the Order WCF Service ============"); Console.WriteLine("Options : "); Console.WriteLine("Press 1 to get Category name"); Console.WriteLine("Press 2 to get Category's product list"); Console.WriteLine("Press 0 to exit."); Console.WriteLine("======================================================"); while(service) { Console.WriteLine("# Enter your opcion 1, 2, 0 : "); int opc = int.Parse(Console.ReadLine()); Console.WriteLine("Enter your category id : "); int id = int.Parse(Console.ReadLine()); switch(opc) { case 1: Console.WriteLine("The category's name is : " + client.GetCategoryNameById(id)); break; case 2: Console.WriteLine("The " + client.GetCategoryNameById(id) + "'s product list : "); var products = client.GetProducts(id); if (products.Count() > 0) { int counter = 1; foreach (ProductEntity p in products) { Console.WriteLine("#" + counter + "Product id : " + p.Id + " Product name : " + p.Name); } } else { Console.WriteLine("Products not found!!!"); } break; case 0: service = false; break; } } Console.WriteLine("Thank you!! :) for use my Order Service"); Console.ReadLine(); }
/// <summary> /// Attempts to get a category and then outputs results to console. /// </summary> /// <param name="id">The ID of the category to retrieve</param> private static void TestGetCategory(int id) { var catService = new CategoryServiceClient(); try { Console.WriteLine(string.Format("\nAttempting to retrieve category {0}.", id)); Category cat = catService.GetCategory(id); Console.WriteLine(string.Format(" - Category Retrieved: ID = {0}, Name = {1}, Description = {2}", cat.ID, cat.Name, cat.Description)); } catch (FaultException ex) { Console.WriteLine(string.Format(" - Get Exception: {0}", ex.Message)); } }
private void PopulateComboboxes() { var catService = new CategoryServiceClient(); cbCategory.DataSource = catService.GetCategories(); cbCategory.DisplayMember = "CategoryName"; cbCategory.ValueMember = "Id"; var ptService = new PaymentTypeServiceClient(); cbPaymentType.DataSource = ptService.GetPaymentTypes(); cbPaymentType.DisplayMember = "Name"; cbPaymentType.ValueMember = "id"; }
public async Task <ActionResult> Delete(string key) { MethodReturnResult result = new MethodReturnResult(); using (CategoryServiceClient client = new CategoryServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format(EDCResources.StringResource.Category_Delete_Success , key); } return(Json(result)); } }
private void btnSet_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(tbPath.Text)) { MessageBox.Show(@"Не выбрано изображение."); return; } using (var serviceClient = new CategoryServiceClient()) { using (var stream = new FileStream(tbPath.Text, FileMode.Open, FileAccess.Read)) { serviceClient.SetCategoryImage((int)cbCategories.SelectedValue, (int)stream.Length, stream); } } MessageBox.Show(@"Изображение отправлено"); }
// // GET: /EDC/Category/ public async Task <ActionResult> Index() { using (CategoryServiceClient client = new CategoryServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Key" }; MethodReturnResult <IList <Category> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new CategoryQueryViewModel())); }
public IEnumerable <SelectListItem> GetCategoryList() { using (CategoryServiceClient client = new CategoryServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("Status='{0}'", Convert.ToInt32(EnumObjectStatus.Available)) }; MethodReturnResult <IList <Category> > result = client.Get(ref cfg); if (result.Code <= 0) { return(from item in result.Data select new SelectListItem() { Text = item.Key, Value = item.Key }); } } return(new List <SelectListItem>()); }
public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { if (ModelState.IsValid) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (CategoryServiceClient client = new CategoryServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <Category> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /EDC/CategoryDetail/ public async Task <ActionResult> Index(string categoryName) { using (CategoryServiceClient client = new CategoryServiceClient()) { MethodReturnResult <Category> result = await client.GetAsync(categoryName ?? string.Empty); if (result.Code > 0 || result.Data == null) { return(RedirectToAction("Index", "Category")); } ViewBag.Category = result.Data; } using (CategoryDetailServiceClient client = new CategoryDetailServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "ItemNo", Where = string.Format(" Key.CategoryName = '{0}'" , categoryName) }; MethodReturnResult <IList <CategoryDetail> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new CategoryDetailQueryViewModel() { CategoryName = categoryName })); }
public ActionResult GetAllCategory() { dynamic category = 0; try { if (ModelState.IsValid) { CategoryServiceClient categoryServiceClient = new CategoryServiceClient(); category = categoryServiceClient.GetAllCategory(); //if (category.Count == 0 || category == null) //{ // ModelState.AddModelError("error", "No Record Found"); //} } } catch (Exception e) { ModelState.AddModelError("error", "Something Wrong"); category = null; throw e; } return(Json(category, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> SaveModify(CategoryViewModel model) { using (CategoryServiceClient client = new CategoryServiceClient()) { MethodReturnResult <Category> result = await client.GetAsync(model.Name); if (result.Code == 0) { result.Data.Status = model.Status; result.Data.Description = model.Description; result.Data.Editor = User.Identity.Name; result.Data.EditTime = DateTime.Now; MethodReturnResult rst = await client.ModifyAsync(result.Data); if (rst.Code == 0) { rst.Message = string.Format(EDCResources.StringResource.Category_SaveModify_Success , model.Name); } return(Json(rst)); } return(Json(result)); } }
public async Task <ActionResult> Save(CategoryViewModel model) { using (CategoryServiceClient client = new CategoryServiceClient()) { Category obj = new Category() { Key = model.Name.ToUpper(), Status = model.Status, Description = model.Description, Editor = User.Identity.Name, EditTime = DateTime.Now, CreateTime = DateTime.Now, Creator = User.Identity.Name }; MethodReturnResult rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(EDCResources.StringResource.Category_Save_Success , model.Name); } return(Json(rst)); } }
public CategoryRepository() { categoryServiceClient = new CategoryServiceClient(); categoryServiceClient.Open(); }
public ProductsController() { prod = new ProductServiceClient(); cate = new CategoryServiceClient(); }
public ShopController() { categoryProxy = new CategoryServiceClient(); orderProxy = new OrderServiceClient(); customerProxy = new CustomerServiceClient(); }