public async Task<ActionResult> Create(EventEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Attachments != null)
                {
                    foreach (var attachment in model.Attachments)
                    {
                        var attachedFile = model.Files.FirstOrDefault(f => f.FileName == attachment.FileName);

                        if (attachedFile != null)
                        {
                            var newName = Guid.NewGuid().ToString() + "_" + Path.GetExtension(attachedFile.FileName);
                            var dir = "~/Public/Attachments/";

                            Directory.CreateDirectory(Server.MapPath(dir));

                            attachedFile.SaveAs(Server.MapPath(dir + newName));

                            model.Event.Attachments.Add(new Attachment
                                {
                                    FileName = newName,
                                    MimeFormat = attachedFile.ContentType,
                                    Size = attachedFile.ContentLength,
                                    Title = attachment.Title
                                });
                        }
                    }
                }

                db.Add(model.Event);
                await db.SaveChangesAsync();

                return RedirectToAction("Index");
            }

            return View(model);
        }
        private EventEditViewModel GenerateViewModel(Event e)
        {
            var model = new EventEditViewModel();
            model.Event = e;

            return model;
        }