예제 #1
0
        public virtual ActionResult Add(NoteModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var staff  = Staff == null?null:this.GetEntity <StaffEntity>(Staff.Id);
            var entity = model.CreateEntity();
            var result = new Dictionary <string, object>();

            entity.Crm = new CrmEntity {
                Id = CrmId
            };
            entity.Name = staff == null?"": staff.Name;
            var rev  = this.SaveEntity(entity);
            var mess = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Id", entity.Id);
            result.Add("Message", mess);
            result.Add("Name", entity.Name);
            result.Add("InsertTime", entity.InsertTime.ToString("yyyy-MM-dd HH:mm"));
            if (rev && model.RemindNoteDate != null)
            {
                var customer = new CustomerEntity
                {
                    Id             = model.CustomerId.Convert <long>(),
                    RemindNoteDate = model.RemindNoteDate.Value,
                    SaveType       = SaveType.Modify
                };
                customer.SetProperty(it => it.RemindNoteDate);
                this.SaveEntity(customer);
            }
            return(this.Jsonp(result));
        }
예제 #2
0
        public virtual ActionResult UpdataStaff(string[] id, string staffId)
        {
            var result = new Dictionary <string, object>();
            var rev    = false;

            if (id != null)
            {
                var infos = new List <CustomerEntity>();
                foreach (var i in id)
                {
                    var info = new CustomerEntity
                    {
                        Id    = i.Convert <long>(),
                        Staff = new StaffEntity {
                            Id = staffId.Convert <long>()
                        },
                        SaveType = SaveType.Modify
                    };
                    info.SetProperty(it => it.Staff.Id);
                    infos.Add(info);
                }
                rev = this.SaveEntities(infos);
            }
            result.Add("Status", rev);
            return(this.Jsonp(result));
        }
예제 #3
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <param name="saveType"></param>
        /// <returns></returns>
        public virtual CustomerEntity CreateEntity(SaveType saveType)
        {
            var entity = new CustomerEntity
            {
                Name = string.IsNullOrWhiteSpace(Name) ? "" : Name,
                Type = new CustomerTypeEntity {
                    Id = TypeId.Convert <long>()
                },
                Channel = new CustomerChannelEntity {
                    Id = TypeId.Convert <long>()
                },
                Gender    = string.IsNullOrWhiteSpace(Gender) ? "" : Gender,
                Qq        = string.IsNullOrWhiteSpace(Qq) ? "" : Qq,
                Linkman   = string.IsNullOrWhiteSpace(Linkman) ? "" : Linkman,
                Weixin    = string.IsNullOrWhiteSpace(Weixin) ? "" : Weixin,
                Mobile    = string.IsNullOrWhiteSpace(Mobile) ? "" : Mobile,
                Telephone = string.IsNullOrWhiteSpace(Telephone) ? "" : Telephone,
                Email     = string.IsNullOrWhiteSpace(Email) ? "" : Email,
                Address   = string.IsNullOrWhiteSpace(Address) ? "" : Address,
                Remark    = string.IsNullOrWhiteSpace(Remark) ? "" : Remark,
                SaveType  = saveType
            };

            entity.RemindNoteDate = string.IsNullOrWhiteSpace(RemindNoteDate)
                ? entity.GetMinDateTime()
                : RemindNoteDate.Convert <DateTime>();
            if (saveType == SaveType.Modify)
            {
                entity.Id = Id.Convert <long>();
                if (Name != null)
                {
                    entity.SetProperty(it => it.Name);
                }
                if (TypeId != null)
                {
                    entity.SetProperty(it => it.Type.Id);
                }
                if (ChannelId != null)
                {
                    entity.SetProperty(it => it.Channel.Id);
                }
                if (Gender != null)
                {
                    entity.SetProperty(it => it.Gender);
                }
                if (Qq != null)
                {
                    entity.SetProperty(it => it.Qq);
                }
                if (Linkman != null)
                {
                    entity.SetProperty(it => it.Linkman);
                }
                if (Weixin != null)
                {
                    entity.SetProperty(it => it.Weixin);
                }
                if (Mobile != null)
                {
                    entity.SetProperty(it => it.Mobile);
                }
                if (Telephone != null)
                {
                    entity.SetProperty(it => it.Telephone);
                }
                if (Email != null)
                {
                    entity.SetProperty(it => it.Email);
                }
                if (Address != null)
                {
                    entity.SetProperty(it => it.Address);
                }
                if (Remark != null)
                {
                    entity.SetProperty(it => it.Remark);
                }
                if (RemindNoteDate != null)
                {
                    entity.SetProperty(it => it.RemindNoteDate);
                }
            }
            return(entity);
        }