public ActionResult Edit(MeetingRoomViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (var database = new MeetingRoomBookingSystemDbContext())
                {
                    var meetingRoom = database
                                      .MeetingRooms
                                      .Where(m => m.Id == model.Id)
                                      .First();

                    meetingRoom.Name            = model.Name;
                    meetingRoom.Capacity        = model.Capacity;
                    meetingRoom.OfficeId        = model.OfficeId;
                    meetingRoom.HasWhiteboard   = model.HasWhiteboard;
                    meetingRoom.HasWorkstations = model.HasWorkstations;
                    meetingRoom.HasMultimedia   = model.HasMultimedia;

                    database.Entry(meetingRoom).State = EntityState.Modified;
                    database.SaveChanges();

                    return(RedirectToAction("Details", new { id = meetingRoom.Id }));
                }
            }

            return(View(model));
        }
        public IActionResult Update([FromBody] CrudViewModel <MeetingRoomViewModel> payload)
        {
            MeetingRoomViewModel value = payload.value;
            var result = _functionalService
                         .Update <MeetingRoomViewModel, MeetingRoom>(value, Convert.ToInt32(value.MeetingRoomId));

            return(Ok());
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> EditMeetingRoom(MeetingRoomViewModel model)
        {
            if (ModelState.IsValid)
            {
                await ContentService.EditMeetingRoom(model);

                ViewBag.IsSuccess = "ok";
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task EditMeetingRoom(MeetingRoomViewModel model)
        {
            var room = await Context.MeetingRooms.FirstOrDefaultAsync(x => x.Id == model.Id);

            if (room != null)
            {
                room.Name            = model.Name;
                room.HaveMarkerBoard = model.HaveMarkerBoard;
                room.HaveProjector   = model.HaveProjector;
                room.NumberOfChair   = model.NumberOfChair;
                await Context.SaveChangesAsync();
            }
        }
Ejemplo n.º 5
0
        public IActionResult MeetingRoom(int id)
        {
            var meetingRoom = _meetingService.GetRoom(id);

            if (meetingRoom == null)
            {
                return(new NotFoundResult());
            }

            var vm = new MeetingRoomViewModel();

            return(View(vm));
        }
        public ActionResult Create()
        {
            using (var database = new MeetingRoomBookingSystemDbContext())
            {
                var model = new MeetingRoomViewModel
                {
                    Offices = database
                              .Offices
                              .OrderBy(o => o.Name)
                              .ToList()
                };

                return(View(model));
            }
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> AddMeetingRoom(MeetingRoomViewModel model)
        {
            if (ModelState.IsValid)
            {
                await ContentService.CreateMeetingRoom(new MeetingRoom
                {
                    Name            = model.Name,
                    HaveMarkerBoard = model.HaveMarkerBoard,
                    HaveProjector   = model.HaveProjector,
                    NumberOfChair   = model.NumberOfChair
                });

                ViewBag.IsSuccess = "ok";
            }
            return(View(model));
        }
        public ActionResult Create(MeetingRoomViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (var database = new MeetingRoomBookingSystemDbContext())
                {
                    var meetingRoom = new MeetingRoom(model.Name,
                                                      model.Capacity,
                                                      model.HasWorkstations,
                                                      model.HasMultimedia,
                                                      model.HasWhiteboard,
                                                      model.OfficeId);

                    database.MeetingRooms.Add(meetingRoom);
                    database.SaveChanges();

                    return(RedirectToAction("Details", new { id = meetingRoom.Id }));
                }
            }

            return(View(model));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            using (var database = new MeetingRoomBookingSystemDbContext())
            {
                var meetingRoom = database
                                  .MeetingRooms
                                  .Where(m => m.Id == id)
                                  .First();

                if (meetingRoom == null)
                {
                    return(HttpNotFound());
                }

                var model = new MeetingRoomViewModel
                {
                    Id              = meetingRoom.Id,
                    Name            = meetingRoom.Name,
                    Capacity        = meetingRoom.Capacity,
                    HasWhiteboard   = meetingRoom.HasWhiteboard,
                    HasWorkstations = meetingRoom.HasWorkstations,
                    HasMultimedia   = meetingRoom.HasMultimedia,
                    OfficeId        = meetingRoom.OfficeId,
                    Offices         = database
                                      .Offices
                                      .OrderBy(o => o.Name)
                                      .ToList()
                };

                return(View(model));
            }
        }
Ejemplo n.º 10
0
        public static IForm <KerioForm> BuildForm()
        {
            OnCompletionAsyncDelegate <KerioForm> processForm = async(context, state) =>
            {
                var xy   = context;
                var resp = ReserveMeeting(state.meetingTime);
                await context.PostAsync("Processing your request response: " + resp);
            };

            FormBuilder <KerioForm> form = new FormBuilder <KerioForm>();

            return(form.Message("Szia!")
                   .Field(nameof(KerioForm.Date), validate:
                          async(_form, val) =>
            {
                ValidateResult result = new ValidateResult();
                var value = val as string;

                _form.meetingTime = DateTime.Today;

                if (value.Contains("ma"))
                {
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("holnap"))
                {
                    _form.meetingTime = DateTime.Today.AddDays(1);
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("hétfő"))
                {
                    int days = ((int)DayOfWeek.Monday - (int)DateTime.Today.DayOfWeek + 7) % 7;
                    _form.meetingTime = _form.meetingTime.AddDays(days);
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("kedd"))
                {
                    int days = ((int)DayOfWeek.Tuesday - (int)DateTime.Today.DayOfWeek + 7) % 7;
                    _form.meetingTime = _form.meetingTime.AddDays(days);
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("szerda"))
                {
                    int days = ((int)DayOfWeek.Wednesday - (int)DateTime.Today.DayOfWeek + 7) % 7;
                    _form.meetingTime = _form.meetingTime.AddDays(days);
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("csütörtök"))
                {
                    int days = ((int)DayOfWeek.Thursday - (int)DateTime.Today.DayOfWeek + 7) % 7;
                    _form.meetingTime = _form.meetingTime.AddDays(days);
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("péntek"))
                {
                    int days = ((int)DayOfWeek.Friday - (int)DateTime.Today.DayOfWeek + 7) % 7;
                    _form.meetingTime = _form.meetingTime.AddDays(days);
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("szombat"))
                {
                    int days = ((int)DayOfWeek.Saturday - (int)DateTime.Today.DayOfWeek + 7) % 7;
                    _form.meetingTime = _form.meetingTime.AddDays(days);
                    result.IsValid = true;
                    return result;
                }
                else if (value.Contains("vasárnap"))
                {
                    int days = ((int)DayOfWeek.Sunday - (int)DateTime.Today.DayOfWeek + 7) % 7;
                    _form.meetingTime = _form.meetingTime.AddDays(days);
                    result.IsValid = true;
                    return result;
                }
                else
                {
                    DateTime date;
                    if (DateTime.TryParseExact(value, DateFormats, new System.Globalization.CultureInfo("hu-HU"), System.Globalization.DateTimeStyles.None, out date))
                    {
                        _form.meetingTime = date.Date;
                        result.IsValid = true;
                        return result;
                    }
                }

                result.IsValid = false;
                result.Feedback = "Ezt az értéket nem ismerem :(";

                return result;
            })
                   .Field(nameof(KerioForm.Time), validate:
                          async(_form, val) =>
            {
                ValidateResult result = new ValidateResult();
                var value = val as string;
                if (value.Contains("dél"))
                {
                    _form.meetingTime = _form.meetingTime.Date.AddHours(12);
                    result.IsValid = true;
                    return result;
                }
                else
                {
                    DateTime time;
                    if (DateTime.TryParseExact(value, TimeFormats, new System.Globalization.CultureInfo("hu-HU"), System.Globalization.DateTimeStyles.None, out time))
                    {
                        _form.meetingTime = _form.meetingTime.Date.AddHours(time.Hour).AddMinutes(time.Minute);
                        result.IsValid = true;
                        return result;
                    }
                }

                result.Feedback = "Nem értem :(";
                result.IsValid = false;

                return result;
            })
                   .Field(nameof(KerioForm.Participants))
                   .Field(nameof(KerioForm.Location), validate: async(state, value) =>
            {
                var res = new ValidateResult();
                var meeting = meetingRooms.FirstOrDefault(x => x.Name.ToLower().Contains(((string)value).ToLower()));
                if (meeting == null)
                {
                    res.Feedback = "Nincs ilyen tárgyaló! :=(";
                    res.IsValid = false;
                    return res;
                }

                KerioForm.meeting = meeting;

                res.Feedback = meeting.Name + " kiválasztva.";
                res.IsValid = true;
                return res;
            }, prompt: GenerateAvLoc())
                   .AddRemainingFields()
                   .OnCompletionAsync(processForm)
                   .Build());
        }