public async Task <IResponse> UpdateAsync(AssigmentModel model)
 {
     model.CreatedUser = $"{_userService.FirstName} {_userService.LastName}";
     if (model.PersonnelId != _userService.PersonnelId && !_userService.IsAdmin)
     {
         return(new ErrorResponse(AspectMessage.AccessDenied));
     }
     return(await _dal.UpdateAsync(_mapper.Map <Assigment>(model)));
 }
        public async Task <IDataResponse <int> > InsertAsync(AssigmentModel model)
        {
            model.CreatedUser = $"{_userService.FirstName} {_userService.LastName}";
            if (model.PersonnelId == 0)
            {
                model.PersonnelId = _userService.PersonnelId;
                return(await _dal.InsertAsync(_mapper.Map <Assigment>(model)));
            }
            var assigment = await _dal.InsertAsync(_mapper.Map <Assigment>(model));

            if (!assigment.Success)
            {
                return(new ErrorDataResponse <int>(assigment.Message));
            }

            var result = await _dalNotify.InsertAsync(new Notification
            {
                Message     = NotificationMessage.Message,
                PersonnelId = model.PersonnelId,
                Title       = NotificationMessage.Title,
                AssigmentId = assigment.Data
            });

            if (!result.Success)
            {
                return(new ErrorDataResponse <int>(result.Message));
            }

            await _dalPersonnelNotify.InsertAsync(new PersonnelNotification
            {
                NotificationId = result.Data,
                PersonnelId    = model.PersonnelId,
            });

            return(assigment);
        }