コード例 #1
0
        public async Task <IHttpActionResult> AddEntrePose(EntrpotInDto entrpotInDto)
        {
            try
            {
                Entrepot entrepot = new Entrepot
                {
                    Id              = IdentityManager.NewId(),
                    User_id         = entrpotInDto.User_id,
                    EntrepotName    = entrpotInDto.EntrepotName,
                    EntrepotDes     = entrpotInDto.EntrepotDes,
                    EntrepotAddress = entrpotInDto.EntrepotAddress
                };
                db.Entrepots.Add(entrepot);
                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "添加成功" }));
                }

                return(Json(new { code = 201, msg = "添加失败" }));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public async Task <IHttpActionResult> EditEntrePose(EntrpotInDto entrpotInDto)
        {
            try
            {
                var Entrepot = new Entrepot {
                    Id = entrpotInDto.Id
                };
                db.Entry(Entrepot).State = System.Data.Entity.EntityState.Unchanged;
                if (!string.IsNullOrWhiteSpace(entrpotInDto.EntrepotName))
                {
                    Entrepot.EntrepotName = entrpotInDto.EntrepotName;
                }
                if (entrpotInDto.User_id != null)
                {
                    Entrepot.User_id = entrpotInDto.User_id;
                }
                if (!string.IsNullOrWhiteSpace(entrpotInDto.EntrepotDes))
                {
                    Entrepot.EntrepotDes = entrpotInDto.EntrepotDes;
                }
                if (!string.IsNullOrWhiteSpace(entrpotInDto.EntrepotAddress))
                {
                    Entrepot.EntrepotAddress = entrpotInDto.EntrepotAddress;
                }
                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "修改成功" }));
                }

                return(Json(new { code = 201, msg = "修改失败" }));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        public async Task <IHttpActionResult> RemoveEntrePose(EntrpotInDto entrpotInDto)
        {
            try
            {
                foreach (var item in entrpotInDto.del_Id)
                {
                    var Entrepot = new Entrepot {
                        Id = item
                    };
                    db.Entry(Entrepot).State = System.Data.Entity.EntityState.Unchanged;
                    Entrepot.del_Enpto       = 1;
                }

                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "删除成功" }));
                }
                return(Json(new { code = 201, msg = "删除失败" }));
            }
            catch (Exception)
            {
                throw;
            }
        }