Beispiel #1
0
        public ActionResult JoinDrawing(DashboardViewModel dashboardViewModel)
        {
            if (dashboardViewModel.JoinDrawingName != null && dashboardViewModel.JoinDrawingPassword != null)
            {
                DrawingDTO drawingToJoin = drawingRepository.ReadDrawingByName(dashboardViewModel.JoinDrawingName);

                if (drawingToJoin != null)
                {
                    if (drawingToJoin.Password == dashboardViewModel.JoinDrawingPassword)
                    {
                        OpenDrawingViewModel vm = new OpenDrawingViewModel();
                        vm.Drawing = drawingToJoin;
                        return(View("Drawing", vm));
                    }
                    else
                    {
                        ModelState.AddModelError("RoomPasswordInvalid", "Wrong password!");
                        return(View("~/Views/Home/Dashboard.cshtml", dashboardViewModel));
                    }
                }
                else
                {
                    ModelState.AddModelError("RoomMissing", "Room with name " + "'" + dashboardViewModel.JoinDrawingName + "'" + " doesn't exist!");
                    return(View("~/Views/Home/Dashboard.cshtml", dashboardViewModel));
                }
            }
            else
            {
                ModelState.AddModelError("MissingParameters", "Please enter the room name and password,");
                return(View("~/Views/Home/Dashboard.cshtml", dashboardViewModel));
            }
        }
Beispiel #2
0
        public ActionResult OpenDrawing(int drawingId, string drawingPassword)
        {
            DrawingDTO drawingToOpen = drawingRepository.ReadDrawing(drawingId);

            OpenDrawingViewModel vm = new OpenDrawingViewModel();

            vm.Drawing = drawingToOpen;

            return(View("Drawing", vm));
        }