Example #1
0
        public async Task <IActionResult> Delivery(int id)
        {
            var order = await _context.Orders.SingleOrDefaultAsync(m => m.Id == id);

            order.Status = 2; //订单状态(0:待付款;1:待发货;2:已发货;3:待评价;4:已完成;10:已取消)
            _context.Update(order);
            await _context.SaveChangesAsync();

            AR.SetSuccess(Messages.AlertActionSuccess);
            return(Json(AR));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Summary,Body,Author,Thumbnail,Pubdate,ViewCount,Active,CategoryId,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Article article)
        {
            if (id != article.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(article);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArticleExists(article.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.ArticleCategories, "Id", "Alias", article.CategoryId);
            return(View(article));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,Title,Description,CreatedDate")] Recipe recipe)
        {
            if (id != recipe.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(recipe);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RecipeExists(recipe.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", recipe.UserId);
            return(View(recipe));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,Importance,Active")] PostCategoryIM im)
        {
            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR));
            }
            if (id != im.Id)
            {
                AR.Setfailure("未发现此分类");
                return(Json(AR));
            }


            try
            {
                var model = await _context.PostCategories.FindAsync(id);

                model             = _mapper.Map(im, model);
                model.UpdatedBy   = User.Identity.Name;
                model.UpdatedDate = DateTime.Now;

                _context.Update(model);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostCategoryExists(im.Id))
                {
                    AR.Setfailure("未发现此分类");
                    return(Json(AR));
                }
                else
                {
                    AR.Setfailure(string.Format(Messages.AlertUpdateFailure, EntityNames.PostCategory));
                    return(Json(AR));
                }
            }
            //  return RedirectToAction(nameof(Index));

            AR.SetSuccess(string.Format(Messages.AlertUpdateSuccess, EntityNames.PostCategory));
            return(Json(AR));
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, TeamIM team)
        {
            if (id != team.Id)
            {
                AR.Setfailure(Messages.HttpNotFound);
                return(Json(AR));
            }

            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR));
            }


            try
            {
                //page.Body = Regex.Replace(page.Body, @"(?i)(?<=<img\b[^>]*?src=(['""]?))(?!http://)[^'""]+(?=\1)", "http://sbe.anyacos.com$0");

                //var ishas = await _context.Pages.CountAsync(d => d.SeoName == page.SeoName.ToLower() && d.Id != id);
                //if (ishas > 0)
                //{
                //    ModelState.AddModelError("SeoName", "已经存在此友好网址");
                //    AR.Setfailure(GetModelErrorMessage());
                //    return Json(AR);
                //}

                var model = await _context.Teams.SingleOrDefaultAsync(d => d.Id == id);

                model             = _mapper.Map(team, model);
                model.UpdatedBy   = User.Identity.Name;
                model.UpdatedDate = DateTime.Now;



                _context.Update(model);
                await _context.SaveChangesAsync();

                AR.SetSuccess(string.Format(Messages.AlertUpdateSuccess, EntityNames.Team));
                return(Json(AR));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PageExists(team.Id))
                {
                    AR.Setfailure(Messages.HttpNotFound);
                    return(Json(AR));
                }
                else
                {
                    throw;
                }
            }
        }
Example #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Thumbnail,Contact,Phone,Address,Province,City,District,Coordinate,Body")] StoreIM store)
        {
            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR));
            }
            var model = await _context.Stores.SingleOrDefaultAsync(d => d.Id == id);

            if (model == null)
            {
                AR.Setfailure(Messages.HttpNotFound);
                return(Json(AR));
            }

            model = _mapper.Map(store, model);



            if (!string.IsNullOrEmpty(store.Coordinate) && store.Coordinate.Contains(","))
            {
                var cod = store.Coordinate.Split(",");
                decimal.TryParse(cod[0], out decimal lng);
                decimal.TryParse(cod[1], out decimal lat);
                model.Longitude = lng;
                model.Latitude  = lat;
            }


            try
            {
                _context.Update(model);
                await _context.SaveChangesAsync();

                AR.SetSuccess(string.Format(Messages.AlertCreateSuccess, EntityNames.Store));
                return(Json(AR));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreExists(store.Id))
                {
                    AR.Setfailure(Messages.HttpNotFound);
                    return(Json(AR));
                }
                else
                {
                    throw;
                }
            }
        }
Example #7
0
        public async Task <IActionResult> Edit(int id, PostIM post)
        {
            if (id != post.Id)
            {
                AR.Setfailure(Messages.HttpNotFound);
                return(Json(AR));
            }

            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR));
            }


            try
            {
                var model = await _context.Posts.SingleOrDefaultAsync(d => d.Id == id);

                model             = _mapper.Map(post, model);
                model.CreatedBy   = User.Identity.Name;
                model.CreatedDate = DateTime.Now;


                _context.Update(model);
                await _context.SaveChangesAsync();

                AR.SetSuccess(string.Format(Messages.AlertUpdateSuccess, EntityNames.Post));
                return(Json(AR));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostExists(post.Id))
                {
                    AR.Setfailure(Messages.HttpNotFound);
                    return(Json(AR));
                }
                else
                {
                    throw;
                }
            }
        }