Beispiel #1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public JsonResult Update(DriverShop entity)
 {
     ModelState.Remove("UpdaterID");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("CreatedTime");
     if (ModelState.IsValid)
     {
         var result = WebService.Update_DriverShop(entity);
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }
Beispiel #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public WebResult <bool> Update_DriverShop(DriverShop model)
        {
            using (DbRepository entities = new DbRepository())
            {
                var oldEntity = entities.DriverShop.Find(model.ID);
                if (oldEntity != null)
                {
                    oldEntity.ProvinceCode  = model.ProvinceCode;
                    oldEntity.CityCode      = model.CityCode;
                    oldEntity.DistrictCode  = model.DistrictCode;
                    oldEntity.Address       = model.Address;
                    oldEntity.ConnactPeople = model.ConnactPeople;
                    oldEntity.Mobile        = model.Mobile;
                    oldEntity.Telephone     = model.Telephone;
                    oldEntity.Sort          = model.Sort;
                    oldEntity.UpdatedTime   = DateTime.Now;
                    oldEntity.Name          = model.Name;
                    oldEntity.UpdaterID     = Client.LoginUser.ID;
                }
                else
                {
                    return(Result(false, ErrorCode.sys_param_format_error));
                }

                if (entities.SaveChanges() > 0)
                {
                    var list  = Cache_Get_DriverShopList();
                    var index = list.FindIndex(x => x.ID.Equals(model.ID));
                    if (index > -1)
                    {
                        list[index] = oldEntity;
                    }
                    else
                    {
                        list.Add(oldEntity);
                    }
                    return(Result(true));
                }
                else
                {
                    return(Result(false, ErrorCode.sys_fail));
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public WebResult <bool> Add_DriverShop(DriverShop model)
 {
     using (DbRepository entities = new DbRepository())
     {
         model.ID          = Guid.NewGuid().ToString("N");
         model.CreatedTime = DateTime.Now;
         model.Flag        = (long)GlobalFlag.Normal;
         model.UpdatedTime = DateTime.Now;
         model.UpdaterID   = Client.LoginUser.ID;
         entities.DriverShop.Add(model);
         if (entities.SaveChanges() > 0)
         {
             var list = Cache_Get_DriverShopList();
             list.Add(model);
             return(Result(true));
         }
         else
         {
             return(Result(false, ErrorCode.sys_fail));
         }
     }
 }