Exemplo n.º 1
0
        public void AddComment(User user, string text, int ball, Guid dish_id)
        {
            Dish dish = this.GetDish(dish_id);

            Comment comment = new Comment();
            comment.User = user;
            comment.Dish = dish;
            comment.Text = text;
            comment.Date = DateTime.Now;
            comment.Ball = ball;

            dish.Comments.Add(comment);

            dish.Rating = this.GetRating(dish);

            this.Entry<Dish>(dish).State = EntityState.Modified;
            this.Comments.Add(comment);

            _IsSavedOrModified = true;
        }
Exemplo n.º 2
0
 public void AddComment(User user, string text, int ball, Guid dish_id)
 {
     _db.AddComment(user, text, ball, dish_id);
 }
Exemplo n.º 3
0
 public void UpdateAvatar(User usr, string fileName)
 {
     _db.UpdateAvatar(usr, fileName);
 }
Exemplo n.º 4
0
        public void Start(HttpContext context, IStoreDB db)
        {
            this._db = db;
            this._httpContext = context;
            HttpCookie cookie = context.Request.Cookies[COOKIE_NAME];

            if (cookie != null && !string.IsNullOrEmpty(cookie.Value))
            {
                FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
                this._user = db.GetUser(ticket.Name);

                if (this.User != null)
                    this.IsAuthentication = true;
                else
                {
                    this.DeleteCookies();
                    this.IsAuthentication = false;
                }
            }
        }
Exemplo n.º 5
0
 public void SetActiveCode(User usr)
 {
     _db.SetActiveCode(usr);
 }
Exemplo n.º 6
0
 public void RegisterUser(User newUser)
 {
     _db.AddUser(newUser);
 }
Exemplo n.º 7
0
        public bool GetUser(string login, out User usr)
        {
            usr = null;

            if (_db.IsContainUser(login))
            {
                usr = _db.GetUser(login);
                return true;
            }
            return false;
        }
Exemplo n.º 8
0
        public void UpdateAvatar(User usr, string fileName)
        {
            usr.AvatarPath = fileName;

            this.Entry<User>(usr).State = EntityState.Modified;

            _IsSavedOrModified = true;
        }
Exemplo n.º 9
0
 public void SetConfirmCode(User usr)
 {
     this.Entry<User>(usr).State = EntityState.Modified;
     _IsSavedOrModified = true;
 }
Exemplo n.º 10
0
        public void TransferMoney(User from, User to, uint money)
        {
            from.Balnce -= (int)money;
            to.Balnce += (int)money;

            if (to.Balnce > 99999999)
                to.Balnce = 99999999;//Дабы при большем значении разметка ломается

            this.Entry<User>(from).State = EntityState.Modified;
            this.Entry<User>(to).State = EntityState.Modified;

            _IsSavedOrModified = true;
        }
Exemplo n.º 11
0
        public void SetActiveCode(User usr)
        {
            usr.IsActive = true;
            usr.ActivationCode = "";
            this.Entry<User>(usr).State = EntityState.Modified;

            _IsSavedOrModified = true;
        }
Exemplo n.º 12
0
 public void RemoveUser(Guid group_id, User removeUser)
 {
     Group grp = this.GetGroup(group_id);
     if (grp.Users.Contains(removeUser))
     {
         grp.Users.Remove(removeUser);
         this.Entry<Group>(grp).State = EntityState.Modified;
         _IsSavedOrModified = true;
     }
     else if (grp.Administrations.Contains(removeUser))
     {
         grp.Administrations.Remove(removeUser);
         this.Entry<Group>(grp).State = EntityState.Modified;
         _IsSavedOrModified = true;
     }
 }
Exemplo n.º 13
0
        public void AddUser(User usr)
        {
            string salt = _saltDB.GetSalt(usr.Id);

            usr.Password = this.Encrypt(usr.Password, salt);
            usr.AvatarPath = "~/img/Standart/Avatar.jpg";

            this.Users.Add(usr);
            base.SaveChanges();
        }
Exemplo n.º 14
0
        public void AddMoney(User usr, uint addMoney)
        {
            usr.Balnce += (int)addMoney;

            if (usr.Balnce > 99999999)
                usr.Balnce = 99999999;//Дабы при большем значении разметка ломается

            this.Entry<User>(usr).State = EntityState.Modified;

            _IsSavedOrModified = true;
        }
Exemplo n.º 15
0
        public void AddMemberInGroup(Guid group_id, User usr)
        {
            Group updateGrp = this.GetGroup(group_id);
            if (!updateGrp.Users.Contains(usr))
            {
                updateGrp.Users.Add(usr);
                this.Entry<Group>(updateGrp).State = EntityState.Modified;

                this._IsSavedOrModified = true;
            }
        }