Example #1
0
 public static List <LoginStat> GetLoginStat(Guid userId)
 {
     using (var ctx = new RentooloEntities())
     {
         return(ctx.LoginStat.Where(x => x.UserId == userId).OrderByDescending(x => x.WhenDate).ToList());
     }
 }
Example #2
0
        public static void SubmitArticle(Articles item)
        {
            using (var ctx = new RentooloEntities())
            {
                if (item.Id == 0)
                {
                    ctx.Articles.Add(item);
                }
                else
                {
                    var obj = ctx.Articles.Single(x => x.Id == item.Id);
                    obj.WhenDate = item.WhenDate;
                    obj.Head     = item.Head;
                    obj.Text     = item.Text;
                    obj.UserId   = item.UserId;
                }

                try
                {
                    ctx.SaveChanges();
                }
                catch (System.Exception ex)
                {
                    DataHelper.AddException(ex);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Добавление значения статистики
        /// Client = 0 - обращение с сайта
        /// Client = 1 - обращение с клиента
        /// </summary>
        public static void AddLoginStatistic(LoginStatistics item)
        {
            using (var ctx = new RentooloEntities())
            {
                if (string.IsNullOrEmpty(item.Version))
                {
                    item.Version = string.Empty;
                }

                var obj = ctx.LoginStatistics.FirstOrDefault(x => x.UserName == item.UserName && x.Ip == item.Ip && x.Client == item.Client && x.Version == item.Version);

                if (obj != null)
                {
                    obj.Count++;
                    obj.WhenLastDate = item.WhenLastDate;
                }
                else
                {
                    ctx.LoginStatistics.Add(item);
                }

                try
                {
                    ctx.SaveChanges();
                }
                catch (System.Exception ex)
                {
                    DataHelper.AddException(ex);
                }
            }
        }
Example #4
0
 public static List <LoginStatistics> GetLoginStatistics(string userName)
 {
     using (var ctx = new RentooloEntities())
     {
         return(ctx.LoginStatistics.Where(x => x.UserName == userName).OrderByDescending(x => x.WhenLastDate).ToList());
     }
 }
Example #5
0
        public static void UpdateUserBalance(Guid userId, CurrenciesEnum currency, double balanceAddition, UpdateBalanceType updateType)
        {
            try
            {
                using (var ctx = new RentooloEntities())
                {
                    var obj = ctx.Wallets.FirstOrDefault(x => x.UserId == userId && x.CurrencyId == (int)currency);
                    if (obj != null)
                    {
                        obj.Value = obj.Value + balanceAddition;
                    }
                    else
                    {
                        Wallets wallet = new Wallets();

                        wallet.Value      = balanceAddition;
                        wallet.UserId     = userId;
                        wallet.CurrencyId = (int)currency;
                        wallet.CreateDate = DateTime.Now;

                        ctx.Wallets.Add(wallet);
                    }

                    ctx.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                DataHelper.AddException(ex);
            }
        }
Example #6
0
 public static bool CheckUserAuthorization(string login, string password)
 {
     using (var dc = new RentooloEntities())
     {
         return(dc.Users.Any(x => x.UserName == login && x.Pwd == password));
     }
 }
Example #7
0
 public static void AddWatched(Guid userId, long advertId)
 {
     using (var ctx = new RentooloEntities())
     {
         ctx.spAddWatched(userId, advertId);
     }
 }
Example #8
0
 public static Auctions GetAuction(int id)
 {
     using (var ctx = new RentooloEntities())
     {
         return(ctx.Auctions.First(x => x.Id == id));
     }
 }
Example #9
0
 public static List <NewsMrshkVV> GetActiveNews()
 {
     using (var db = new RentooloEntities())
     {
         return(db.NewsMrshkVV.Where(n => n.Active).OrderByDescending(n => n.Date).ToList());
     }
 }
Example #10
0
 public static void AddWatchedByCookies(string userCookiesId, long advertId)
 {
     using (var ctx = new RentooloEntities())
     {
         ctx.spAddWatchedByCookies(userCookiesId, advertId);
     }
 }
Example #11
0
 public static List <Rates> GetRates()
 {
     using (var ctx = new RentooloEntities())
     {
         return(ctx.Rates.ToList());
     }
 }
Example #12
0
 public static Rates GetLastRates()
 {
     using (var ctx = new RentooloEntities())
     {
         return(ctx.Rates.OrderByDescending(item => item.Id).FirstOrDefault());
     }
 }
Example #13
0
        public static List <Tenders> GetTenders(TendersFilter filter)
        {
            using (var dc = new RentooloEntities())
            {
                var tenders = dc.Tenders.Select(x => x);

                if (filter.Name != null)
                {
                    tenders = tenders.Where(x => x.Name.Contains(filter.Name));
                }

                if (filter.MinCost != null)
                {
                    tenders = tenders.Where(x => x.Cost >= filter.MinCost);
                }

                if (filter.MaxCost != null)
                {
                    tenders = tenders.Where(x => x.Cost <= filter.MaxCost);
                }



                return(tenders.ToList());
            }
        }
Example #14
0
 public static List <Comments> GetComments(int type, int advertId)
 {
     using (var dc = new RentooloEntities())
     {
         return(dc.Comments.Where(x => (x.Type == type) && (x.AdvertId == advertId)).ToList());
     }
 }
        public static void SubmitNewsVark(NewsVark item)
        {
            using (var ctx = new RentooloEntities())
            {
                if (item.Id == 0)
                {
                    ctx.NewsVark.Add(item);
                }
                else
                {
                    var obj = ctx.NewsVark.Single(x => x.Id == item.Id);
                    obj.Date       = item.Date;
                    obj.Text       = item.Text;
                    obj.CreateDate = item.CreateDate;
                    obj.AuthorId   = item.AuthorId;
                    obj.Active     = item.Active;
                }

                try
                {
                    ctx.SaveChanges();
                }
                catch (System.Exception ex)
                {
                    DataHelper.AddException(ex);
                }
            }
        }
Example #16
0
 public static void AddFavorites(Favorites item)
 {
     using (var ctx = new RentooloEntities())
     {
         ctx.spAddFavorites(item.UserId, item.AdvertId);
     }
 }
Example #17
0
 public static int GetUserViewsCount(int objectId, int type)
 {
     using (var dc = new RentooloEntities())
     {
         return(dc.UserViews.Where(x => (x.ObjectId == objectId) && (x.Type == type)).Count());
     }
 }
Example #18
0
        public static List <RentForPage> GetRent(Guid userId)
        {
            using (var ctx = new RentooloEntities())
            {
                var result = ctx.Rent.Where(x => x.UserOwnerId == userId).ToList();

                List <RentForPage> list = new List <RentForPage>();

                foreach (var item in result)
                {
                    list.Add(new RentForPage
                    {
                        Id              = item.Id,
                        Title           = item.Title,
                        Created         = item.Created,
                        DateEnd         = (DateTime)item.DateEnd,
                        DateStart       = item.DateStart,
                        MinuteRentPrice = (int)item.MinuteRentPrice,
                        HourRentPrice   = (int)item.HourRentPrice,
                        DayRentPrice    = item.DayRentPrice,
                        ImgUrls         = item.ImgUrls
                    });
                }

                return(list);
            }
        }
Example #19
0
        public static List <FavoritesForPage> GetFavoritesByCookies(string uid)
        {
            using (var ctx = new RentooloEntities())
            {
                System.Data.Objects.ObjectResult <spGetFavoritesByCookies_Result> result = ctx.spGetFavoritesByCookies(uid);

                List <FavoritesForPage> list = new List <FavoritesForPage>();

                foreach (var item in result)
                {
                    list.Add(new FavoritesForPage
                    {
                        Id               = item.Id,
                        AdvertId         = item.AdvertId,
                        CreatedFavorites = item.CreatedFavorites,
                        Category         = item.Category,
                        Name             = item.Name,
                        Description      = item.Description,
                        CreatedAdverts   = item.CreatedAdverts.Value,
                        CreatedUserId    = item.CreatedUserId.Value,
                        Price            = item.Price.Value,
                        Address          = item.Address,
                        Phone            = item.Phone,
                        MessageType      = item.MessageType.Value,
                        Position         = item.PositionString
                    });
                }

                return(list);
            }
        }
Example #20
0
        public static List <FavoritesForPage> GetFavoritesByUserEF(Guid userId)
        {
            using (var ctx = new RentooloEntities())
            {
                List <Favorites> result = ctx.Favorites.Where(x => x.UserId == userId).ToList();

                List <FavoritesForPage> list = new List <FavoritesForPage>();

                foreach (var item in result)
                {
                    list.Add(new FavoritesForPage
                    {
                        Id       = item.Id,
                        AdvertId = item.AdvertId,
                        //CreatedFavorites = item.CreatedFavorites,
                        //Category = item.Category,
                        //Name = item.Name,
                        //Description = item.Description,
                        //CreatedAdverts = item.CreatedAdverts.Value,
                        //CreatedUserId = item.CreatedUserId.Value,
                        //Price = item.Price.Value,
                        //Address = item.Address,
                        //Phone = item.Phone,
                        //MessageType = item.MessageType.Value,
                        //Position = item.PositionString
                    });
                }

                return(list);
            }
        }
Example #21
0
 public static Rent GetRent(int id)
 {
     using (var ctx = new RentooloEntities())
     {
         return(ctx.Rent.First(x => x.Id == id));
     }
 }
Example #22
0
        public static List <FavoritesForPage> GetFavoritesByUserSqlQuery(Guid userId)
        {
            using (var ctx = new RentooloEntities())
            {
                string query = string.Format("SELECT * FROM Favorites WHERE UserId = '{0}'", userId);

                var result = ctx.Database.SqlQuery <FavoritesForPage>(query).ToList();

                List <FavoritesForPage> list = new List <FavoritesForPage>();

                foreach (var item in result)
                {
                    list.Add(new FavoritesForPage
                    {
                        Id       = item.Id,
                        AdvertId = item.AdvertId,
                        //CreatedFavorites = item.CreatedFavorites,
                        //Category = item.Category,
                        //Name = item.Name,
                        //Description = item.Description,
                        //CreatedAdverts = item.CreatedAdverts.Value,
                        //CreatedUserId = item.CreatedUserId.Value,
                        //Price = item.Price.Value,
                        //Address = item.Address,
                        //Phone = item.Phone,
                        //MessageType = item.MessageType.Value,
                        //Position = item.PositionString
                    });
                }

                return(list);
            }
        }
Example #23
0
        public static List <FavoritesForPage> GetFavoritesByUser(Guid userId)
        {
            using (var ctx = new RentooloEntities())
            {
                var result = ctx.spGetFavorites(userId);

                List <FavoritesForPage> list = new List <FavoritesForPage>();

                foreach (var item in result)
                {
                    list.Add(new FavoritesForPage
                    {
                        Id               = item.Id,
                        AdvertId         = item.AdvertId,
                        CreatedFavorites = item.CreatedFavorites,
                        Category         = item.Category,
                        Name             = item.Name,
                        Description      = item.Description,
                        CreatedAdverts   = item.CreatedAdverts.Value,
                        CreatedUserId    = item.CreatedUserId.Value,
                        Price            = item.Price.Value,
                        Address          = item.Address,
                        Phone            = item.Phone,
                        MessageType      = item.MessageType.Value,
                        Position         = item.PositionString,
                        ImgUrls          = item.ImgUrls
                    });
                }

                return(list);
            }
        }
Example #24
0
 public static void AddRentRequest(Rent auctionRequest)
 {
     using (var ctx = new RentooloEntities())
     {
         ctx.Rent.Add(auctionRequest);
         ctx.SaveChanges();
     }
 }
Example #25
0
 public static TenderRequest GetWinedTRequest(int tenderId)
 {
     using (var dc = new RentooloEntities())
     {
         var tRequest = dc.TenderRequest.First(x => (x.TenderId == tenderId) && (x.DateWin != null));
         return(tRequest);
     }
 }
Example #26
0
 public static void CreateTenderRequest(TenderRequest request)
 {
     using (var dc = new RentooloEntities())
     {
         dc.TenderRequest.Add(request);
         dc.SaveChanges();
     }
 }
Example #27
0
 public static void CreateTender(Tenders tender)
 {
     using (var dc = new RentooloEntities())
     {
         dc.Tenders.Add(tender);
         dc.SaveChanges();
     }
 }
Example #28
0
 public static void UpdateTReqStatusEnd(int tRequestId)
 {
     using (var dc = new RentooloEntities())
     {
         dc.TenderRequest.First(x => x.Id == tRequestId).DateStart = DateTime.Now;
         dc.SaveChanges();
     }
 }
Example #29
0
 public static List <TenderRequest> GetTenderRequests(int id)
 {
     using (var dc = new RentooloEntities())
     {
         var trequests = dc.TenderRequest.Where(x => x.TenderId == id).ToList();
         return(trequests);
     }
 }
Example #30
0
 public static List <Tenders> GetUsersTenders(Guid id)
 {
     using (var dc = new RentooloEntities())
     {
         var tenders = dc.Tenders.Where(x => x.UserOwnerId == id);
         return(tenders.ToList());
     }
 }