Example #1
0
        public static bool UpdateAnimal(AnimalUpdate editedAnimal)
        {
            try
            {
                using (AnimalInformationContext databaseModel = new AnimalInformationContext())
                {
                    var v = databaseModel.AnimalInformations.SingleOrDefault(a => a.PKAnimalId == editedAnimal.PKAnimalId);
                    if (v != null)
                    {
                        v.AnimalCodeName = editedAnimal.AnimalCodeName;
                        v.AnimalTypeId   = editedAnimal.AnimalType;
                        v.Comments       = editedAnimal.Comments;
                        v.DateofEntry    = editedAnimal.DateofEntry;
                        v.DateofExit     = editedAnimal.DateofExit;
                        v.Gender         = editedAnimal.Gender;
                        v.IsDeleted      = editedAnimal.IsDeleted;

                        databaseModel.SaveChanges();
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ec)
            {
                return(false);
            }
        }
Example #2
0
        public static AnimalWeightInfoView AnimalWeightViewFormatSingle(AnimalWeight request)
        {
            AnimalWeightInfoView returnList = new AnimalWeightInfoView();

            try
            {
                using (AnimalInformationContext contex = new AnimalInformationContext())
                {
                    var animalinfo = contex.AnimalInformations.Include("animalType").Where(a => a.PKAnimalId == request.AnimalId).FirstOrDefault();

                    returnList.animalId       = animalinfo.PKAnimalId;
                    returnList.Date           = request.Date;
                    returnList.animalCodeName = animalinfo.AnimalCodeName;
                    returnList.gender         = animalinfo.Gender;
                    returnList.animalType     = animalinfo.animalType.AnimalTypeName;
                    returnList.Weight         = request.Weight;
                    returnList.animalTypeId   = animalinfo.AnimalTypeId;

                    return(returnList);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Example #3
0
        public static bool CowHeatUpdate(CowHeat updatedHeatInfo)
        {
            try
            {
                using (AnimalInformationContext databaseModel = new AnimalInformationContext())
                {
                    var v = databaseModel.CowHeat.SingleOrDefault(a => a.AnimalId == updatedHeatInfo.AnimalId && a.HeatDate == updatedHeatInfo.HeatDate.Date);
                    if (v != null)
                    {
                        v.ActualDeliveryDate   = updatedHeatInfo.ActualDeliveryDate;
                        v.AnimalId             = updatedHeatInfo.AnimalId;
                        v.DeliveryStatus       = updatedHeatInfo.DeliveryStatus;
                        v.ExpectedDeliveryDate = updatedHeatInfo.ExpectedDeliveryDate;
                        v.HeatDate             = updatedHeatInfo.HeatDate;
                        v.HeatSummary          = updatedHeatInfo.HeatSummary;
                        v.HeatTime             = updatedHeatInfo.HeatTime;
                        v.InjectedDate         = updatedHeatInfo.InjectedDate;
                        v.InjectedTime         = updatedHeatInfo.InjectedTime;
                        v.NextHeatDate         = updatedHeatInfo.NextHeatDate;
                        v.OperatorName         = updatedHeatInfo.OperatorName;

                        databaseModel.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ec)
            {
                return(false);
            }
        }
Example #4
0
        public static List <AnimalWeightInfoView> AnimalWeightViewFormat(List <AnimalWeight> request)
        {
            List <AnimalWeightInfoView> returnList = new List <AnimalWeightInfoView>();

            try
            {
                using (AnimalInformationContext contex = new AnimalInformationContext())
                {
                    foreach (var tem in request)
                    {
                        var animalinfo = contex.AnimalInformations.Include("animalType").Where(a => a.PKAnimalId == tem.AnimalId).FirstOrDefault();
                        returnList.Add(new AnimalWeightInfoView
                        {
                            animalId       = tem.AnimalId,
                            Date           = tem.Date,
                            animalCodeName = animalinfo.AnimalCodeName,
                            gender         = animalinfo.Gender,
                            animalType     = animalinfo.animalType.AnimalTypeName,
                            Weight         = tem.Weight,
                            animalTypeId   = animalinfo.AnimalTypeId
                        });
                    }
                    return(returnList);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Example #5
0
 //--------------------   Animal Vaccine  -------------------------------------
 #region
 public static bool AddAnimalVaccine(AnimalVaccineAdd newentry, string operatorname)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var animal = AnimalInformationDBAcces.GetAnimalInfoByID(newentry.AnimalId);
             if (animal != null)
             {
                 Vaccination add = new Vaccination();
                 add.AnimalId          = newentry.AnimalId;
                 add.VaccinationDate   = newentry.VaccinationDate;
                 add.VaccineName       = newentry.VaccineName;
                 add.NextVaccationDate = newentry.NextVaccationDate;
                 add.Comments          = newentry.Comments;
                 add.IsApplied         = true;
                 add.OperatorName      = operatorname;
                 datamodel.Vaccinations.Add(add);
                 datamodel.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="areaID"></param>
 /// <returns></returns>
 public static List <AnimalInformation> GetAnimalByAnimalTypeId(int animaltypeid)
 {
     try
     {
         using (AnimalInformationContext dataModel = new AnimalInformationContext())
         {
             var v = dataModel.AnimalInformations.Where(a => a.AnimalTypeId == animaltypeid).ToList();
             return(v);
         }
     }
     catch (Exception)
     { return(null); }
 }
Example #7
0
 public static AnimalInformation GetAnimalInfoByID(int animalID)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             return(databaseModel.AnimalInformations.SingleOrDefault(a => a.PKAnimalId == animalID));
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #8
0
 public static List <AnimalInformation> GetEnabledFemaleAnimalByTypeId(int typeid)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             return(databaseModel.AnimalInformations.Include("animalType").Where(a => a.IsDeleted == false && a.Gender.ToLower() == "female" && a.AnimalTypeId == typeid).ToList());
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #9
0
 public static List <AnimalInformation> GetDisabledAnimalList()
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             return(databaseModel.AnimalInformations.Where(a => a.IsDeleted == true).ToList());
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #10
0
 public static List <AnimalInformation> GetNumberofEnabledAnimal(int numberofRows)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             return(databaseModel.AnimalInformations.Include("animalType").Where(a => a.IsDeleted == false).Take(numberofRows).ToList());
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #11
0
 public static AnimalWeight GetWeightInfoByIDDate(int id, DateTime date)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             return(databaseModel.AnimalWeight.SingleOrDefault(a => a.AnimalId == id && a.Date == date.Date));
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #12
0
 public static List <AnimalWeight> GetNumberofWeightedAnimal(int numberofRows)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             return(databaseModel.AnimalWeight.Where(a => a.animal.IsDeleted == false).Take(numberofRows).ToList());
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #13
0
        //-------------------- Cow Heat -------------------------------------
        #region

        public static List <AnimalInformation> GetAvailableAnimalforHeat()
        {
            try
            {
                using (AnimalInformationContext datamodel = new AnimalInformationContext())
                {
                    var v = datamodel.AnimalInformations.Where(a => a.IsDeleted == false).ToList();
                    return(v);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Example #14
0
 public static List <MilkProduction> GetMilkProductionList(DateTime min, DateTime max)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             var v = databaseModel.MilkProduction.Include("animal").Where(a => a.Date >= min && a.Date <= max).ToList();
             return(v);
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #15
0
 public static Vaccination GetVccineById(int id)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.Vaccinations.Include("animal").Where(a => a.PKVaccinationId == id).SingleOrDefault();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #16
0
 public static List <AnimalInformation> GetAnimalListByAnimalTypeId(int animalTypeId)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             var v = databaseModel.AnimalInformations.Where(a => a.IsDeleted == false && a.AnimalTypeId == animalTypeId).ToList();
             return(v);
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #17
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public static List <MilkProduction> GetallMilkProductionByDate(DateTime date)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             var v = databaseModel.MilkProduction.Include("animal").Where(a => a.Date == date).ToList();
             return(v);
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #18
0
 public static List <CowHeat> GetHeatListforDateRange(DateTime minDate, DateTime maxDate)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.CowHeat.Where(a => a.HeatDate >= minDate.Date && a.HeatDate <= maxDate.Date).ToList();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #19
0
 public static List <Vaccination> GetAvailableVaccines()
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.Vaccinations.Include("animal").ToList();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #20
0
 public static MedicineCourse GetMedicationDoseByIdanddate(int id, DateTime date)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.MedicineCourses.Where(a => a.medicationId == id && a.MedicationDate == date).SingleOrDefault();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #21
0
 public static List <AnimalType> GetDisabledAnimalType()
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.AnimalTypes.Where(a => a.IsDeleted == true).ToList();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #22
0
 public static List <MedicineCourse> GetAvailableMedicinedose()
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.MedicineCourses.Include("medicine").ToList();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #23
0
 public static Medication IsMedicineExistsByNameandDate(string medicinename, DateTime date, int animalid)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.Medication.SingleOrDefault(a => a.MedicationDate == date && a.MedicineName == medicinename && a.AnimalId == animalid);
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #24
0
 public static List <MedicineCourse> GetAvailableMedicinedose(DateTime max, DateTime min)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.MedicineCourses.Include("medicine").Where(a => a.MedicationDate >= min && a.MedicationDate <= max).ToList();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #25
0
 public static List <Vaccination> GetAvailableVaccines(DateTime max, DateTime min)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             var v = datamodel.Vaccinations.Include("animal").Where(a => a.VaccinationDate >= min && a.VaccinationDate <= max).ToList();
             return(v);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #26
0
 public static CowHeat GetHeatInfoByIDDate(int id, DateTime date)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             var v = databaseModel.CowHeat.SingleOrDefault(a => a.AnimalId == id && a.HeatDate == date.Date);
             return(v);
         }
     }
     catch (Exception ec)
     {
         return(null);
     }
 }
Example #27
0
        //--------------------   Animal Weight -------------------------------------
        #region

        public static List <AnimalInformation> GetAvailableAnimalforWeightInput()
        {
            try
            {
                using (AnimalInformationContext databaseModel = new AnimalInformationContext())
                {
                    var allAnimal = databaseModel.AnimalInformations.Include("animalType").Where(a => a.IsDeleted == false).ToList();
                    return(allAnimal);
                }
            }
            catch (Exception ec)
            {
                return(null);
            }
        }
Example #28
0
 public static bool AddAnimalType(AnimalType animalType)
 {
     try
     {
         using (AnimalInformationContext databaseModel = new AnimalInformationContext())
         {
             databaseModel.AnimalTypes.Add(animalType);
             databaseModel.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #29
0
 public static bool AddHeat(CowHeat newHeatInfo)
 {
     try
     {
         using (AnimalInformationContext datamodel = new AnimalInformationContext())
         {
             datamodel.CowHeat.Add(newHeatInfo);
             datamodel.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #30
0
        public static bool AddMedicationDose(MedicineCourse newentry)
        {
            try
            {
                using (AnimalInformationContext datamodel = new AnimalInformationContext())
                {
                    datamodel.MedicineCourses.Add(newentry);
                    datamodel.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }