public Response <FollowUpDTO> SendSMSAlertToOneChild(int childId) { try { using (VDEntities entities = new VDEntities()) { var dbChildFollowup = entities.FollowUps.Where(x => x.ChildID == childId).OrderByDescending(x => x.ID).FirstOrDefault(); UserSMS.ParentFollowUpSMSAlert(dbChildFollowup); FollowUpDTO followupDTO = Mapper.Map <FollowUpDTO>(dbChildFollowup); return(new Response <FollowUpDTO>(true, null, followupDTO)); } } catch (Exception ex) { return(new Response <FollowUpDTO>(false, GetMessageFromExceptionObject(ex), null)); } }
public Response <List <FollowUpDTO> > SendSMSAlertToAllChildren(int GapDays, int doctorId) { try { using (VDEntities entities = new VDEntities()) { DateTime AddedDateTime = DateTime.UtcNow.AddHours(5).AddDays(GapDays); List <FollowUp> dbFollowUps = new List <FollowUp>(); if (GapDays == 0) { dbFollowUps = entities.FollowUps.Where(x => x.DoctorID == doctorId && x.NextVisitDate == DateTime.UtcNow.AddHours(5).Date) .OrderByDescending(x => x.ID).ToList(); } if (GapDays > 0) { dbFollowUps = entities.FollowUps.Where(x => x.DoctorID == doctorId && x.NextVisitDate >= DateTime.UtcNow.AddHours(5).Date&& x.NextVisitDate <= AddedDateTime) .OrderByDescending(x => x.ID).ToList(); } if (GapDays < 0) { dbFollowUps = entities.FollowUps.Where(x => x.DoctorID == doctorId && x.NextVisitDate <= DateTime.UtcNow.AddHours(5).Date&& x.NextVisitDate >= AddedDateTime) .OrderByDescending(x => x.ID).ToList(); } foreach (FollowUp followup in dbFollowUps) { UserSMS.ParentFollowUpSMSAlert(followup); } List <FollowUpDTO> dbFollowDTOs = Mapper.Map <List <FollowUpDTO> >(dbFollowUps); return(new Response <List <FollowUpDTO> >(true, null, dbFollowDTOs)); } } catch (Exception ex) { return(new Response <List <FollowUpDTO> >(false, GetMessageFromExceptionObject(ex), null)); } }