//dayalerts פונקציה שממלאה את טבלת public static bool initDayAlertsList(UserMedicines userMedicine) { try { TimeSpan c = DateTime.Today.Subtract(userMedicine.fromDate.Value); if (c.TotalDays % userMedicine.frequency == 0) { List <Alerts> listAlerts = Connect.DB.Alerts.Where(p => p.userMedicineId == userMedicine.id).ToList(); for (var i = 0; i < listAlerts.Count; i++) { DayAlerts dayAlert = new DayAlerts() { alertId = listAlerts[i].id, isTaken = false, date = DateTime.Today, }; bool da = addDayAlert(dayAlert); } } return(true); } catch (Exception e) { return(false); } }
public static UserMedicine UserMedicineToModel(UserMedicines UserMedicineEntity) { return(new UserMedicine() { id = UserMedicineEntity.id, amount = UserMedicineEntity.amount, frequency = UserMedicineEntity.frequency, fromDate = UserMedicineEntity.fromDate.Value, medicineId = UserMedicineEntity.medicineId, timesADay = UserMedicineEntity.timesADay, toDate = UserMedicineEntity.toDate, userId = UserMedicineEntity.userId, unitsInStock = UserMedicineEntity.unitsInStock, medicineName = UserMedicineEntity.medicine.medicineName, }); //return new UserMedicine() //{ // id = UserMedicineEntity.id, // amount = UserMedicineEntity.amount, // frequency = UserMedicineEntity.frequency, // fromDate = UserMedicineEntity.fromDate, // medicineId = UserMedicineEntity.medicineId, // timesADay = UserMedicineEntity.timesADay, // toDate = UserMedicineEntity.toDate, // userId = UserMedicineEntity.userId, // unitsInStock = UserMedicineEntity.unitsInStock, // medicineName = UserMedicineEntity.medicine.medicineName //}; }
public static bool deleteMedicine(UserMedicine medicine) { try { UserMedicines userMedicine = Converters.UserMedicineConvert.UserMedicineToEntity(medicine); userMedicine = Connect.DB.UserMedicines.Single(m => m.id == medicine.id); // userMedicine = Connect.DB.UserMedicines.Attach(userMedicine); Connect.DB.UserMedicines.Remove(userMedicine); Connect.DB.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public static UserMedicines UserMedicineToEntity(UserMedicine userMedicineModel) { UserMedicines medicin = new UserMedicines() { id = userMedicineModel.id, amount = userMedicineModel.amount, frequency = userMedicineModel.frequency, fromDate = userMedicineModel.fromDate, medicineId = userMedicineModel.medicineId, timesADay = userMedicineModel.timesADay, toDate = userMedicineModel.toDate, userId = userMedicineModel.userId, unitsInStock = userMedicineModel.unitsInStock, }; return(medicin); }