Наследование: PageBase_Admin
Пример #1
0
        public async Task <ActionResult> Save(CategoryDetailViewModel model)
        {
            using (CategoryDetailServiceClient client = new CategoryDetailServiceClient())
            {
                CategoryDetail obj = new CategoryDetail()
                {
                    Key = new CategoryDetailKey()
                    {
                        CategoryName  = model.CategoryName.ToUpper(),
                        ParameterName = model.ParameterName.ToUpper()
                    },
                    ItemNo     = model.ItemNo,
                    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.CategoryDetail_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
        // Get All Category for Id
        public CategoryDetail GetCategory(int id)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .Categories
                             .SingleOrDefault(e => e.CategoryId == id);
                var category = new CategoryDetail()
                {
                    CategoryId   = entity.CategoryId,
                    CategoryName = entity.CategoryName,
                    Entries      = entity.Entries.Select(e => new CheckingListItem()
                    {
                        CheckingId   = e.CheckingId,
                        CheckingName = e.CheckingName,
                        MonthlyBill  = e.MonthlyBill,
                        ChargeDate   = e.ChargeDate,
                        DateCleared  = e.DateCleared,
                        Cleared      = e.Cleared,


                        UtilityComapny = e.UtilityCompany.UtilityCompanyId + " " + e.UtilityCompany.UtilityName,

                        Category = e.Category.CategoryId + " " + e.Category.CategoryName,

                        Description = e.Description.DescriptionId + " " + e.Description.DescriptionName,


                        PayingBy = e.PayingBy.PayById + " " + e.PayingBy.PayById
                    }).ToList()
                };

                return(category);
            }
        }
Пример #3
0
        public ActionResult GetCategoryById(int id)
        {
            CategoryDetail category = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44320/api/");
                string token = DeserializeToken();
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

                var responseTask = client.GetAsync("category/" + id.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <CategoryDetail>();
                    readTask.Wait();

                    category = readTask.Result;
                }
                else
                {
                    ModelState.AddModelError(string.Empty, result.Content.ReadAsStringAsync().Result);
                }
            }
            return(View(category));
        }
Пример #4
0
        public async Task <IActionResult> CategoryDetail(CategoryDetail model)
        {
            var user = await GetCurrentUserAsync();

            if (user != null)
            {
                var role = await _userManager.GetRolesAsync(user);

                TempData["userRole"] = role[0];
                if (ModelState.IsValid)
                {
                    if (model.CategoryId != 0)
                    {
                        _context.CategoryDetail.Update(model);
                        _context.SaveChanges();
                    }
                    else
                    {
                        model.SortOrder = _context.CategoryDetail.Max(a => a.SortOrder) + 1;
                        _context.CategoryDetail.Add(model);
                        _context.SaveChanges();
                    }
                }
                return(RedirectToAction("Categories", "Admin"));
            }
            else
            {
                return(RedirectToAction("QuickRegister", "Account"));
            }
        }
        public IActionResult Put(int id, CategoryDetail categoryDetail)
        {
            CategoryDetailBO categoryDetailBO;
            ObjectResult     response;

            try
            {
                _log.LogInformation($"Starting Put( {id}, '{JsonConvert.SerializeObject(categoryDetail, Formatting.None)}')");

                categoryDetailBO = new CategoryDetailBO(_loggerFactory, _config);

                categoryDetail.ID = id;
                categoryDetail    = categoryDetailBO.Update(categoryDetail);

                response = Ok(categoryDetail);

                _log.LogInformation($"Finishing Put( {id} )");
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                response = StatusCode(500, ex.Message);
            }

            return(response);
        }
        private List <CategoryDetail> Load(DataSet data)
        {
            List <CategoryDetail> categoryDetails;
            CategoryDetail        categoryDetail;

            try
            {
                categoryDetails = new List <CategoryDetail>();

                foreach (DataRow row in data.Tables[0].Rows)
                {
                    categoryDetail = new CategoryDetail();

                    categoryDetail.ID         = row.Field <int>("ID");
                    categoryDetail.CategoryID = row.Field <int>("CategoryID");

                    categoryDetail.Name        = row.Field <string>("Name");
                    categoryDetail.TitleIconID = row.Field <string>("TitleIconID");

                    categoryDetail.LoadUrls(_config);

                    categoryDetails.Add(categoryDetail);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(categoryDetails);
        }
Пример #7
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,CategorySubID,SeoDescription,HtmlDescription,SeoKeywords")] CategoryDetail categoryDetail)
        {
            if (id != categoryDetail.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoryDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryDetailExists(categoryDetail.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategorySubID"] = new SelectList(_context.CategorySubs, "ID", "Name", categoryDetail.CategorySubID);
            return(View(categoryDetail));
        }
Пример #8
0
        /// <summary>
        /// 获取详细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public PublicResult <CategoryDetail> GetCategoryDetail(GetCategoryDetailDto dto)
        {
            Category category = null;

            using (var client = DbFactory.CreateClient())
            {
                category = client.Queryable <Category>().InSingle(dto.Id);
            }
            if (category == null)
            {
                return(null);
            }

            var res = new CategoryDetail
            {
                Id          = category.Id,
                Name        = category.Name,
                Alias       = category.Alias,
                Description = category.Description,
                OrderIndex  = category.OrderIndex,
                ParentId    = category.ParentId,
                Path        = category.Path
            };

            return(res);
        }
        public CategoryDetail Update(CategoryDetail categoryDetail)
        {
            SqlHelper  dataConnection;
            SqlCommand command;

            try
            {
                dataConnection = new SqlHelper(_loggerFactory, _config);

                command = new SqlCommand($@"UPDATE CategoryDetail SET

											 Name = @Name
											,CategoryID = @CategoryID
											,TitleIconID = @TitleIconID

											WHERE ID = @ID"                                            );

                command.Parameters.AddWithValue("ID", categoryDetail.ID.AsDbValue());
                command.Parameters.AddWithValue("Name", categoryDetail.Name.AsDbValue());
                command.Parameters.AddWithValue("CategoryID", categoryDetail.CategoryID.AsDbValue());
                command.Parameters.AddWithValue("TitleIconID", categoryDetail.TitleIconID.AsDbValue());

                dataConnection.ExecuteNonQuery(command);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(categoryDetail);
        }
Пример #10
0
        public async Task <IActionResult> PutCategoryDetail([FromRoute] long id, [FromBody] CategoryDetail categoryDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != categoryDetail.CategoryId)
            {
                return(BadRequest());
            }

            _context.Entry(categoryDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #11
0
        public async Task <IActionResult> PutTodoItem(int id, CategoryDetail todoItem)
        {
            eCommerceEntities _context = new eCommerceEntities();

            if (id != todoItem.CategoryId)
            {
                return(BadRequest());
            }

            _context.Entry(todoItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TodoItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #12
0
 /// <summary>
 /// add as an asynchronous operation.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <returns>Task&lt;MethodReturnResult&gt;.</returns>
 public async Task <MethodReturnResult> AddAsync(CategoryDetail obj)
 {
     return(await Task.Run <MethodReturnResult>(() =>
     {
         return base.Channel.Add(obj);
     }));
 }
Пример #13
0
        public async Task <ActionResult <CategoryDetail> > PostCategoryDetail(CategoryDetail categoryDetail)
        {
            _context.CategoryDetails.Add(categoryDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategoryDetail", new { id = categoryDetail.CategoryId }, categoryDetail));
        }
Пример #14
0
        public ActionResult UpdateCategory(CategoryDetail cd)
        {
            if (ModelState.IsValid)
            {
                Category cat = _unitOfWork.GetRepositoryInstance <Category>().GetFirstOrDefault(cd.CategoryId);
                cat = cat != null ? cat : new Category();
                cat.CategoryName = cd.CategoryName;
                if (cd.CategoryId != 0)
                {
                    _unitOfWork.GetRepositoryInstance <Category>().Update(cat);
                    _unitOfWork.SaveChanges();
                }
                else
                {
                    cat.IsActive = true;
                    cat.IsDelete = false;
                    _unitOfWork.GetRepositoryInstance <Category>().Add(cat);
                }

                return(RedirectToAction("Categories"));
            }
            else
            {
                return(View("UpdateCategory", cd));
            }
        }
Пример #15
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            CatDetail            = e.Parameter as MenuItem;
            ButtonBack.IsEnabled = this.Frame.CanGoBack;
            CategoryDetail catDetail = await _categoryService.CategoryDetail(CatDetail.id);

            ProductList.ItemsSource = catDetail.data.foods;
        }
Пример #16
0
        /// <summary>
        /// 编辑经营类目页面 韦德 2018年9月26日14:50:11
        /// </summary>
        /// <returns></returns>
        [AuthenticationFilter(Role = "admin")] public ActionResult EditView(int?categoryId)
        {
            CategoryDetail categoryDetail  = CategoryService.GetCategoryDetail(categoryId.Value);
            var            categoryDetails = CategoryService.GetCategoryDetails().Where(c => c.ParentId == 0).ToList();

            ViewBag.CategoryList = categoryDetails;
            return(PartialView(categoryDetail));
        }
Пример #17
0
        public string Create(CategoryDetail category)
        {
            category.CategoryDetailId = Guid.NewGuid() + DateTime.Now.ToString("ddMMyyyy - hhmmss");
            category.CreateDate       = DateTime.Now;
            _CategoryDetai.Add(category);

            return("success");
        }
Пример #18
0
        public bool UpdateCategory(CategoryDetail model)
        {
            var category = _ctx.Categories.Single(p => p.CategoryId == model.CategoryId);

            category.CategoryId = model.CategoryId;
            category.Name       = model.Name;
            return(_ctx.SaveChanges() == 1);
        }
Пример #19
0
        private async void search_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (search.Text == "")
            {
                CategoryDetail catDetail = await categoryServices.CategoryDetail(CatDetail.id);

                ProductList.ItemsSource = catDetail.data.foods;
            }
        }
Пример #20
0
        public CategoryDetail GetCategoryDetail(int id)
        {
            var category = _categoryRepository.Get(id);
            var detail   = new CategoryDetail
            {
                Description = category.Description,
                CreatedOn   = category.CreatedOn
            };

            return(detail);
        }
Пример #21
0
        public void AddCategories(CategoryDetail category)
        {
            using (dbMyOnlineShoppingEntities db = new dbMyOnlineShoppingEntities())
            {
                Tbl_Category CA = new Tbl_Category();
                CA.CategoryName = category.CategoryName;

                db.Tbl_Category.Add(CA);
                db.SaveChanges();
            }
        }
Пример #22
0
        public async Task <IActionResult> Create([Bind("ID,Name,CategorySubID,SeoDescription,HtmlDescription,SeoKeywords")] CategoryDetail categoryDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categoryDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategorySubID"] = new SelectList(_context.CategorySubs, "ID", "Name", categoryDetail.CategorySubID);
            return(View(categoryDetail));
        }
Пример #23
0
 public static bool ReqUpdateCategory(CategoryDetail cd)
 {
     using (var context = new ContosoContext())
     {
         var category = context.Categories.Single(s => s.CategoryID == cd.CategoryId);
         category.CategoryName = cd.CategoryName;
         category.Description  = cd.Description;
         category.Picture      = cd.Picture;
         context.SaveChanges();
         return(true);
     }
 }
Пример #24
0
        public async Task <IActionResult> PostCategoryDetail([FromBody] CategoryDetail categoryDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CategoryDetail.Add(categoryDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategoryDetail", new { id = categoryDetail.CategoryId }, categoryDetail));
        }
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        CategoryDetail cd = new CategoryDetail {
            CategoryName = txtCatName.Text,
            IsActive     = Convert.ToInt32(DDLIsActive.SelectedItem.Value)
        };
        DataClassesDataContext dcdc = new DataClassesDataContext();

        dcdc.CategoryDetails.InsertOnSubmit(cd);
        dcdc.SubmitChanges();
        gvCategory.DataBind();
        txtCatName.Text = "";
    }
Пример #26
0
 public IActionResult CreateCategory(CategoryDetail model)
 {
     if (ModelState.IsValid)
     {
         Tbl_Category category = new Tbl_Category();
         category.CategoryName = model.CategoryName;
         category.IsActive     = model.IsActive;
         category.IsDelete     = model.IsDelete;
         cat_repository.Insert(category);
         return(RedirectToAction("AllCategories"));
     }
     return(View(model));
 }
        public ActionResult UpdateCategory(int categoryId)
        {
            CategoryDetail cd;

            if (categoryId != null)
            {
                cd = JsonConvert.DeserializeObject <CategoryDetail>(JsonConvert.SerializeObject(_unitOfWork.GetRepositoryInstance <Tbl_Category>().GetFirstorDefault(categoryId)));
            }
            else
            {
                cd = new CategoryDetail();
            }
            return(View("UpdateCategory", cd));
        }
Пример #28
0
        private async void FontIconUp_Tapped(object sender, TappedRoutedEventArgs e)
        {
            List <Product> listSearch = new List <Product>();
            CategoryDetail catDetail  = await categoryServices.CategoryDetail(CatDetail.id);

            if (catDetail != null)
            {
                foreach (var item in catDetail.data.foods)
                {
                    listSearch.Add(item);
                }
                ProductList.ItemsSource = listSearch.OrderBy(K => K.price).ToList();
            }
        }
Пример #29
0
        public ActionResult UpdateCategory(int categoryID)
        {
            CategoryDetail cd;

            if (categoryID != 0)
            {
                cd = JsonConvert.DeserializeObject <CategoryDetail>(JsonConvert.SerializeObject(_unitofWork.GetRepositoryInstance <Tbl_Category>().GetFirstDefault(categoryID)));
            }
            else
            {
                cd = new CategoryDetail();
            }
            return(View("UpdateCategory", cd)); /*call view of update category */
        }
Пример #30
0
        public async Task <EntityResult <CategoryDetail> > UpdateAsync(CategoryDetail categoryDetail)
        {
            EntityResult <CategoryDetail> result = new EntityResult <CategoryDetail>();

            try
            {
                result = await httpClient.PutJsonAsync <EntityResult <CategoryDetail> >($"{Config.ApiUrl}/api/services/app/Category/Update", categoryDetail);
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Error   = ex.Message;
            }
            return(result);
        }