コード例 #1
0
 public List<VaccinationPrice> GetList()
 {
     using (var db = new VaccinationManagerEntities())
     {
         return db.VaccinationPrices.ToList();
     }
 }
コード例 #2
0
        public decimal FindPriceByFaccinationId(string inputVaccinationDefId)
        {
            try
            {
                using (var db = new VaccinationManagerEntities())
                {
                    var obj = db.VaccinationPrices.FirstOrDefault(p => p.VaccinationDefId == inputVaccinationDefId);
                    if (obj == null)
                    {
                        return -1;
                    }
                    else
                    {
                        return obj.PriceAmount;
                    }
                }
            }
            catch (Exception)
            {

                return -1;
            }
        }
コード例 #3
0
        public bool AddVaccinationPrice(string inputVaccinationDefId, decimal inputAmount, bool isInitialize = false)
        {
            try
            {
                
                using (var db = new VaccinationManagerEntities())
                {
                    var obj = db.VaccinationPrices.FirstOrDefault(p => p.VaccinationDefId == inputVaccinationDefId);

                    if (obj == null)
                    {
                        obj = new VaccinationPrice
                        {
                            VaccinationDefId = inputVaccinationDefId,
                            PriceAmount = inputAmount
                        };

                        db.VaccinationPrices.Add(obj);
                        
                    }
                    else
                    {
                        if (!isInitialize)
                        {
                            obj.PriceAmount = inputAmount;
                        }
                    }
                    db.SaveChanges();
                    return true;
                }
            }
            catch (Exception exception)
            {

                return false;
            }
        }