Ejemplo n.º 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));
        }