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

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

            try
            {
                var model = ExpressOrderTemplate.ObjectSet().Where(s => s.Id == dto.Id && s.AppId == dto.AppId).FirstOrDefault();
                if (model != null)
                {
                    model.EntityState = EntityState.Deleted;
                    ContextFactory.CurrentThreadContext.SaveObject(model);

                    var items = ExpressOrderTemplateProperty.ObjectSet().Where(e => e.TemplateId == model.Id).ToList();
                    foreach (var item in items)
                    {
                        item.EntityState = EntityState.Deleted;
                        ContextFactory.CurrentThreadContext.SaveObject(item);
                    }

                    ContextFactory.CurrentThreadContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                result.isSuccess = false;
                result.Message   = "删除失败";
                LogHelper.Error("删除模板异常", ex);
            }

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

            if (dto == null || dto.AppId == Guid.Empty || string.IsNullOrEmpty(dto.TemplateName) || string.IsNullOrEmpty(dto.ExpressCode) || (string.IsNullOrEmpty(dto.ExpressImage) && dto.Id == Guid.Empty) || dto.Width < 0 || dto.Height < 0)
            {
                result.isSuccess = false;
                result.Message   = "参数错误";
                return(result);
            }

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

                var model = ExpressOrderTemplate.ObjectSet().Where(d => d.TemplateName == dto.TemplateName && d.AppId == dto.AppId && d.Status == 0 && d.TemplateType == 1 && d.Id != dto.Id).FirstOrDefault();
                if (model != null)
                {
                    result.isSuccess = false;
                    result.Message   = "重复名称";
                }
                else
                {
                    if (dto.Id != Guid.Empty)
                    {
                        model = ExpressOrderTemplate.ObjectSet().Where(d => d.Id == dto.Id).FirstOrDefault();
                        if (model != null)
                        {
                            model.TemplateName = dto.TemplateName;
                            model.ExpressCode  = dto.ExpressCode;
                            model.Width        = dto.Width;
                            model.Height       = dto.Height;
                            if (!string.IsNullOrEmpty(dto.ExpressImage))
                            {
                                model.ExpressImage = dto.ExpressImage;
                            }
                            model.ModifiedOn  = DateTime.Now;
                            model.EntityState = EntityState.Modified;
                            ContextFactory.CurrentThreadContext.SaveChanges();
                        }
                        else
                        {
                            result.isSuccess = false;
                            result.Message   = "数据不存在";
                        }
                    }
                    else
                    {
                        dto.Id            = Guid.NewGuid();
                        dto.Status        = 0;
                        dto.TemplateType  = 1;
                        dto.CreateTime    = DateTime.Now;
                        dto.ModifiedOn    = dto.CreateTime;
                        model             = ExpressOrderTemplate.FromDTO(dto);
                        model.EntityState = EntityState.Added;
                        ContextFactory.CurrentThreadContext.SaveObject(model);
                        ContextFactory.CurrentThreadContext.SaveChanges();
                    }
                }
                if (model != null)
                {
                    result.Data = model.ToEntityData();
                }
                else
                {
                    result.Data = dto;
                }
            }
            catch (Exception ex)
            {
                result.isSuccess = false;
                result.Message   = "保存异常";
                LogHelper.Error("保存模板异常", ex);
            }

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