Ejemplo n.º 1
0
        public IActionResult Create(CreateMeetingViewModel vm)
        {
            var presenter = _presenterFactory.Create(MessageHandler, ErrorHandler);

            if (!ModelState.IsValid)
            {
                return(View(presenter.Present(vm)));
            }

            var request = vm.ToRequest(CurrentUserId);

            try
            {
                var uc       = _useCaseFactory.Create;
                var response = uc.Execute(request);
                return(RedirectToAction(nameof(Index), new { id = presenter.Present(response) }));
            }
            catch (InvalidRequestException ire)
            {
                presenter.PresentErrors(ire.Message, ire.Errors);
                return(View(presenter.Present(vm)));
            }
            catch (Exception e)
            {
                presenter.PresentMessage(MessageType.Error, e.Message);
                return(View(presenter.Present(vm)));
            }
        }
Ejemplo n.º 2
0
 public ActionResult Create()
 {
     var ctx = new ApplicationDbContext();
     var model = new CreateMeetingViewModel
     {
         MeetingTimes = new List<MeetingTime>(),
         AllUsers = ctx.Users.ToList()
     };
     return View(model);
 }
Ejemplo n.º 3
0
        public ActionResult CreateMeeting()
        {
            CreateMeetingViewModel model = new CreateMeetingViewModel();
            var          uid             = User.Identity.GetUserId();
            var          gp  = db.GroupPersons.Where(g => g.User.Id == uid).ToList();
            List <Group> gro = new List <Group>();

            for (var i = 0; i < gp.Count; i++)
            {
                gro.Add(gp[i].Group);
            }
            model.Groups = gro;
            return(View(model));
        }
 public static CreateMeetingRequest ToRequest(this CreateMeetingViewModel vm, string userId)
 {
     return(new CreateMeetingRequest(userId)
     {
         Name = vm.Name,
         Description = vm.Description,
         ProjectId = Identity.FromString(vm.Project.Id),
         OrganizedBy = Identity.FromString(vm.OrganizedBy.Id),
         InvolvedPersons = vm.SelectedPersonIds.Select(Identity.FromString),
         Time = DateTime.ParseExact(vm.Time, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture),
         Duration = DateTime.ParseExact(vm.Duration, "HH:mm", CultureInfo.InvariantCulture).TimeOfDay,
         Log = vm.Log,
         Documents = vm.SelectedDocumentIds.Select(Identity.FromString),
     });
 }
Ejemplo n.º 5
0
        private async Task <CreateMeetingViewModel> ConfigureLists(CreateMeetingViewModel model, int Id)
        {
            foreach (var member in await memberRepository.GetMembers())
            {
                var item = new SelectListItem
                {
                    Value = member.Id.ToString(),
                    Text  = member.Name
                };
                model.AddMember(item);
            }
            model.PresentMembers = memberRepository.GetMembersInEvent(Id);

            return(model);
        }
Ejemplo n.º 6
0
        public static ViewModelSection GetNewSection(ViewModels viewType, IServiceProvider _service)
        {
            ViewModelSection retView = null;

            switch (viewType)
            {
            case ViewModels.PlaneMeeting:
                retView      = new PlaneMeetingViewModel(_service);
                retView.Name = "Інформація про засідання";
                break;

            case ViewModels.Issues:
                retView      = new IssuesViewModel(_service);
                retView.Name = "Огляд протоколів";
                break;

            case ViewModels.ReqistryOfDecisions:
                retView      = new RegistryViewModel(_service);
                retView.Name = "Реєстр рішень";
                break;

            case ViewModels.Protocols:
                retView      = new ProtocolsViewModel(_service);
                retView.Name = "Перелік протоколів";
                break;

            case ViewModels.Filter:
                retView      = new FilterViewModel(_service);
                retView.Name = "Фільтр";
                break;

            case ViewModels.CreateMeeting:
                retView      = new CreateMeetingViewModel(_service);
                retView.Name = "Планування нового засідання";
                break;

            default:
                break;
            }

            return(retView);
        }
Ejemplo n.º 7
0
        public ActionResult CrMeeting(CreateMeetingViewModel model)
        {
            Meeting newM = new Meeting();

            newM.Name = model.Name;
            var Date = Request.Form["Datepck"].ToString();
            var Time = Request.Form["Timepck"].ToString();

            newM.Date = Date;
            newM.Time = Time;
            var Gro   = Request.Form["selGroup"].ToString();
            int groid = int.Parse(Gro);
            var gr    = db.Groups.Where(g => g.GId == groid).Single();

            newM.Group = gr;

            MeetingInvitation mi = new MeetingInvitation();

            mi.Meeting = newM;
            var usi = User.Identity.GetUserId();
            var us  = db.Users.Where(u => u.Id == usi).Single();

            mi.Invitee = us;
            mi.Status  = "Accepted";
            List <MeetingInvitation> ffs = new List <MeetingInvitation>();

            ffs.Add(mi);
            newM.Participants = ffs;
            if (us.InvitationsToMeetings == null)
            {
                us.InvitationsToMeetings = ffs;
            }
            else
            {
                us.InvitationsToMeetings.Add(mi);
            }
            db.Meetings.Add(newM);
            db.MeetingInvitations.Add(mi);
            db.Users.Attach(us);
            db.SaveChanges();
            return(RedirectToAction("MeetingList", "Meeting"));
        }
Ejemplo n.º 8
0
 public CreateMeetingViewModel Present(CreateMeetingViewModel vm)
 {
     vm.Persons   = Persons();
     vm.Documents = Documents(Identity.FromString(vm.Project.Id));
     return(vm);
 }