Ejemplo n.º 1
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO RemoveExt(Jinher.AMP.BTP.Deploy.ExpressCodeDTO dto)
        {
            ResultDTO result = new ResultDTO()
            {
                isSuccess = true
            };

            if (dto == null || dto.Id == Guid.Empty)
            {
                result.isSuccess = false;
                result.Message   = "参数不能为空";
                return(result);
            }

            try
            {
                var id    = dto.Id;
                var model = ExpressCode.ObjectSet().Where(s => s.Id == id).FirstOrDefault();
                if (model != null)
                {
                    model.EntityState = EntityState.Deleted;
                    ContextFactory.CurrentThreadContext.SaveObject(model);
                    ContextFactory.CurrentThreadContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                result.isSuccess = false;
                result.Message   = "删除失败";
                LogHelper.Error("删除快递异常", ex);
            }

            return(result);
        }
Ejemplo n.º 2
0
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO Remove(Jinher.AMP.BTP.Deploy.ExpressCodeDTO dto)
 {
     base.Do();
     return(this.RemoveExt(dto));
 }
Ejemplo n.º 3
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.ExpressCodeDTO> SaveExt(Jinher.AMP.BTP.Deploy.ExpressCodeDTO dto)
        {
            ResultDTO <ExpressCodeDTO> result = new ResultDTO <ExpressCodeDTO>()
            {
                isSuccess = true
            };

            if (dto == null || string.IsNullOrEmpty(dto.ExpCompanyName) || string.IsNullOrEmpty(dto.ExpCode))
            {
                result.isSuccess = false;
                result.Message   = "参数错误";
                return(result);
            }

            try
            {
                dto.ExpCompanyName = dto.ExpCompanyName.Replace(" ", "");

                var model = ExpressCode.ObjectSet().Where(d => (d.ExpCompanyName == dto.ExpCompanyName || d.ExpCode == dto.ExpCode) && d.Id != dto.Id).FirstOrDefault();
                if (model != null)
                {
                    result.isSuccess = false;
                    result.Message   = "重复名称或者编码";
                }
                else
                {
                    if (dto.Id != Guid.Empty)
                    {
                        model = ExpressCode.ObjectSet().Where(d => d.Id == dto.Id).FirstOrDefault();
                        if (model != null)
                        {
                            model.ExpCompanyName = dto.ExpCompanyName;
                            model.ExpCode        = dto.ExpCode;
                            model.EntityState    = EntityState.Modified;
                            ContextFactory.CurrentThreadContext.SaveChanges();
                        }
                        else
                        {
                            result.isSuccess = false;
                            result.Message   = "数据不存在";
                        }
                    }
                    else
                    {
                        dto.Id = Guid.NewGuid();
                        model.ExpCompanyName = dto.ExpCompanyName;
                        model.ExpCode        = dto.ExpCode;
                        model.EntityState    = EntityState.Added;
                        ContextFactory.CurrentThreadContext.SaveObject(model);
                        ContextFactory.CurrentThreadContext.SaveChanges();
                    }
                }

                result.Data = dto;
            }
            catch (Exception ex)
            {
                result.isSuccess = false;
                result.Message   = "保存异常";
                LogHelper.Error("保存快递异常", ex);
            }

            return(result);
        }
Ejemplo n.º 4
0
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.ExpressCodeDTO> Save(Jinher.AMP.BTP.Deploy.ExpressCodeDTO dto)
 {
     base.Do();
     return(this.Command.Save(dto));
 }