Пример #1
0
 public void AddToGroup(string id, string entityName, string groupName)
 {
     //The lock is created before the compiler reaches this point.
     //That's why the necessity of checking the absence of a lock for the user that is joining to the waiting group.
     if (!_lockManager.HasLock(int.Parse(id), entityName, _userManager.GetUserName(Context.User)))
     {
         Groups.AddToGroupAsync(Context.ConnectionId, groupName);
     }
 }
Пример #2
0
        public IActionResult Edit(int id, EventDTO obj, string cancel, string notify)
        {
            string _user      = _userManager.GetUserName(this.User);
            string _groupName = $"{_entityName}-{id}";

            if (!string.IsNullOrEmpty(cancel))
            {
                if (_lockRepository.HasLock(obj.Id, _entityName, _user))
                {
                    _lockRepository.ReleaseLock(obj.Id, _entityName, _user);
                    _signalREventService.InformLockReleased(_groupName, id, _user);
                }

                return(RedirectToAction("index"));
            }

            if (!string.IsNullOrEmpty(notify))
            {
                TempData["Notification"] = "You will be notified as soon as the user finish working on this document.";
                return(View(obj));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repository.Update(_mapper.Map <Event>(obj), _user);
                    _signalREventService.InformLockReleased(_groupName, id, _user);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (ConcurrencyException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(obj));
                }
            }
            return(View(obj));
        }