public bool SaveCrmActivity(CrmActivityInfo req) { if (string.IsNullOrWhiteSpace(Provider.CurrentMember.Id)) { throw new APIException("Access is denied"); } var cr = new CrmActivity(); req.CopyPropertiesWithSameName(cr); cr.MemberId = Provider.CurrentMember.Id; cr.Save(); Job j = new Job() { Command = JobCommands.NewTicket, Executer = JobExecuters.Staff, ExecuterId = Provider.CurrentMember.StaffMemberId.IsEmpty() ? Provider.Api.GetNextIdleStaffMemberId(Departments.Marketing) : Provider.CurrentMember.StaffMemberId, Name = "New ticket from " + cr.Member().FullName, RelatedEntityName = "CrmActivity", RelatedEntityId = cr.Id, State = JobStates.NotStarted }; j.Save(); return(true); }
public List <CrmActivityInfo> GetCrmActivities(ReqEmpty req) { if (string.IsNullOrWhiteSpace(Provider.CurrentMember.Id)) { throw new APIException("Access is denied"); } var entities = Provider.Database.ReadList <CrmActivity>( @" SELECT ca.*, j.State FROM CrmActivity ca, Job j WHERE j.RelatedEntityId = ca.Id AND j.RelatedEntityName = 'CrmActivity' AND ca.MemberId = {0} AND ca.IsDeleted = 0 ORDER BY ca.InsertDate desc", Provider.CurrentMember.Id); var dtos = new List <CrmActivityInfo>(); foreach (var e in entities) { var dto = new CrmActivityInfo(); e.CopyPropertiesWithSameName(dto); dto.State = (JobStates)Enum.Parse(typeof(JobStates), (string)e["State"]); dto.ReplyCount = Provider.Database.GetInt("select count(*) from CrmActivityMessage where CrmActivityId = {0}", e.Id); dtos.Add(dto); } return(dtos); }
public bool SaveCrmActivity(CrmActivityInfo req) { return(Call <bool, CrmActivityInfo>(req, MethodBase.GetCurrentMethod().Name)); }