示例#1
0
 public static void SnimiDb(ModelEF db)
 {
     try
     {
         db.SaveChanges();
     }
     catch (DbEntityValidationException dbEx)
     {
         Greskonja(dbEx);
     }
 }
示例#2
0
        public static Double RacunajRatu(Models.Company komp)
        {
            double rata = 0;

            try {
                using (ModelEF db = new ModelEF())
                {
                    var prvi = db.Companies.Include(x => x.Transactions).FirstOrDefault(x => x.Active && x.CompanyId == komp.CompanyId);
                    if (prvi != null && prvi.Transactions != null && prvi.Transactions.Count > 0)
                    {
                        var trki = prvi.Transactions.Where(x => x.Active && x.TransactionType == PrevodSrb.Produkcija);
                        if (trki.Count() > 0)
                        {
                            rata = trki.OrderByDescending(x => x.TransactionDate).FirstOrDefault().Amount;
                        }
                    }
                }
            }
            catch { };


            return(rata);
        }