public async Task <bool> AddLocation(Location location)
        {
            try
            {
                context.Add(location);
                int x = await context.SaveChangesAsync();

                if (x == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch { return(false); }
        }
Exemple #2
0
        public int AddUserRole(int UserID, int RoleID = 3)
        {
            try
            {
                UserRole ur = new UserRole
                {
                    RoleID = RoleID,
                    UserID = UserID
                };
                Debug.WriteLine("_______________________Objekar userRole kreiran.______________________-");
                context.Add(ur);

                Debug.WriteLine("_______________________Objekar userRole Dodat u kontekst.______________________-");
                context.SaveChanges();
                Debug.WriteLine("_______________________Objekar userRole dodat u bazu.______________________-");

                return(ur.UserRoleID);
            }
            catch (Exception ex) { Debug.WriteLine(ex.Message);
                                   return(0); }
        }
Exemple #3
0
 /// <summary>
 /// Adds defined entity into db
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity"></param>
 public void Add <T>(T entity) where T : class
 {
     context.Add(entity);
 }