Esempio n. 1
0
        /// <summary>
        /// Removes user from shareitWith
        /// </summary>
        /// <param name="shareItId"></param>
        /// <param name="userId"></param>
        public void RemoveUserFromShareIt(long shareItId, long userId)
        {
            awShareItWith shareItWith = _context.awShareItWiths.
                                        FirstOrDefault(s => s.shareItId.Equals(shareItId) && s.userId.Equals(userId));

            if (shareItWith == null)
            {
                return;
            }

            _context.awShareItWiths.DeleteOnSubmit(shareItWith);
            _context.SubmitChanges();
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="shareItIds"></param>
        /// <param name="blogId"></param>
        public void AddUsersToShareIt(long shareItId, long[] userIds)
        {
            //Delete the users first
            var alreadyExist = from l in _context.awShareItWiths
                               where l.shareItId.Equals(shareItId)
                               select l;

            if (alreadyExist != null && alreadyExist.Count() > 0)
            {
                _context.awShareItWiths.DeleteAllOnSubmit(alreadyExist);
            }

            foreach (long uId in userIds)
            {
                awShareItWith sw = new awShareItWith();
                sw.shareItWithId = AWAPI_Common.library.MiscLibrary.CreateUniqueId();
                sw.shareItId     = shareItId;
                sw.userId        = uId;
                sw.createDate    = DateTime.Now;
                _context.awShareItWiths.InsertOnSubmit(sw);
            }

            _context.SubmitChanges();
        }