private void Kontrol() { List <Cattle> cattles = cattleDAL.GetAll().Where(x => x.Inseminations.Count() > 0 && x.Inseminations.Last().Result == true && (DateTime.Now.Subtract(x.Inseminations.Last().Date).Days == 45)).ToList(); foreach (var item in cattles) { try { string[] tokens = new string[tokenDAL.GetAll().Where(x => x.RanchID == item.RanchID).Count()]; int counter = 0; foreach (var item2 in tokenDAL.GetAll().Where(x => x.RanchID == item.RanchID)) { tokens[counter] = item2.DeviceToken; counter++; } string title = item.EarringNumber + " Küpeli Hayvanı Bilgilendirme : "; string body = item.Name + " isimli hayvanın tohumlanma günü 45 gün olmuştur.Kontrol ettiriniz !!!"; var push = PushNotificationLogic.SendPushNotification(tokens, title, body, new { action = "Mühendis Bey Süt", userId = 5 }); SmtpClient sc = new SmtpClient("smtp.muhendisbeysut.com"); sc.Port = 587; sc.EnableSsl = false; sc.UseDefaultCredentials = false; sc.Credentials = new NetworkCredential("*****@*****.**", "SIFRE"); sc.TargetName = "STARTTLS/smtp.muhendisbeysut.com"; MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**", "ÇiftlikApp Bilgilendirme"); mail.To.Add(item.Ranch.Email); mail.Subject = title; mail.IsBodyHtml = true; mail.Body = body; sc.Send(mail); } catch (Exception) { throw; } } }
public List <Cattle> GetCattlesByCattleTypeID(int cattleTypeID, int RanchID) { List <Cattle> cattles = cattleDAL.GetAll().Where(x => x.CattleTypeID == cattleTypeID && x.RanchID == RanchID).ToList(); return(cattles); }