Ejemplo n.º 1
0
 public ActionResult Post([FromBody] AssignmentUserChatRoomModel assignmentUserChatRoom)
 {
     try
     {
         return(this.SuccessResponse(this._chatRoomService.RegisterAssignmentUserChatRoom(assignmentUserChatRoom)));
     }
     catch (Exception e)
     {
         return(this.BadRequest(e.Message));
     }
 }
Ejemplo n.º 2
0
        public AssignmentUserChatRoomModel RegisterAssignmentUserChatRoom(AssignmentUserChatRoomModel assignmentUserChatRoom)
        {
            AssignmentUserChatRoomEntity assignmentUserChatRoomEntity = this._chatRoomContext.AssignmentUserChatRooms
                                                                        .Include(x => x.ChatRoom)
                                                                        .Where(x => x.Id == assignmentUserChatRoom.ChatRoomId)
                                                                        .Where(x => x.UserId == assignmentUserChatRoom.UserId).FirstOrDefault();

            if (assignmentUserChatRoomEntity != null)
            {
                throw new Exception("Currently exist this user in the chat room:" + assignmentUserChatRoomEntity.ChatRoom.Name);
            }
            assignmentUserChatRoom.Status = StatusEnum.Active.GetDescription();
            assignmentUserChatRoomEntity  = Mapper.MapAssignmentUserChatRoomModelToAssignmentUserChatRoomEntity(assignmentUserChatRoom);
            this.InsertAssignmentUserChatRoom(assignmentUserChatRoomEntity);
            return(Mapper.MapAssignmentUserChatRoomEntityToAssignmentUserChatRoomModel(assignmentUserChatRoomEntity));
        }
Ejemplo n.º 3
0
 public static AssignmentUserChatRoomEntity MapAssignmentUserChatRoomModelToAssignmentUserChatRoomEntity(AssignmentUserChatRoomModel assignmentUserChatRoom)
 {
     return(new AssignmentUserChatRoomEntity
     {
         ChatRoomId = assignmentUserChatRoom.ChatRoomId,
         Id = assignmentUserChatRoom.Id,
         Status = assignmentUserChatRoom.Status,
         UserId = assignmentUserChatRoom.UserId
     });
 }