public async Task <ActionResult> Edit(GroupImageModel model)
        {
            var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name));

            if (!(user.IsGroupAdmin && user.GroupId == model.Group.Id))
            {
                return(RedirectToAction("NotAuthorized", "Error"));
            }
            try
            {
                var group = await GroupFacade.GetGroupAsync(model.Group.Id);

                var relativePath = group.Picture;
                if (model.File != null && model.File.ContentLength > 0)
                {
                    var fileType = Path.GetExtension(model.File.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Img/"), model.Group.Id + fileType);
                    model.File.SaveAs(path);
                    relativePath        = "/Img/" + model.Group.Id + fileType;
                    model.Group.Picture = relativePath;
                }
                model.Group.Picture = relativePath;
                await GroupFacade.Edit(model.Group);
            }
            catch (Exception ex)
            {
                ViewBag.Message = "ERROR: " + ex.Message.ToString();
            }
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Edit(Guid id)
        {
            var group = await GroupFacade.GetGroupAsync(id);

            return(View("Edit", new GroupImageModel {
                Group = group, File = null
            }));
        }
        public async Task <ActionResult> Edit(Guid id)
        {
            var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name));

            if (user.IsGroupAdmin && user.GroupId == id)
            {
                var group = await GroupFacade.GetGroupAsync(id);

                return(View(new GroupImageModel {
                    Group = group, File = null
                }));
            }
            return(RedirectToAction("NotAuthorized", "Error"));
        }
        public async Task <ActionResult> Details(Guid id)
        {
            var user = await CharacterFacade.GetCharacterById(Guid.Parse(User.Identity.Name));

            var model = await GroupFacade.GetGroupAsync(id);

            if (model == null || user == null)
            {
                return(RedirectToAction("List"));
            }
            if (user.GroupId == model.Id)
            {
                ViewBag.GroupMember = true;
                if (user.IsGroupAdmin)
                {
                    ViewBag.GroupAdmin = true;
                }
            }
            model.Wall = model.Wall.OrderByDescending(x => x.Timestamp).ToList();
            return(View("Details", model));
        }
        public async Task <ActionResult> Edit(GroupImageModel model)
        {
            try
            {
                var group = await GroupFacade.GetGroupAsync(model.Group.Id);

                var relativePath = group.Picture;
                if (model.File != null && model.File.ContentLength > 0)
                {
                    var fileType = Path.GetExtension(model.File.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Img/"), model.Group.Id + fileType);
                    model.File.SaveAs(path);
                    relativePath        = "/Img/" + model.Group.Id + fileType;
                    model.Group.Picture = relativePath;
                }
                model.Group.Picture = relativePath;
                await GroupFacade.Edit(model.Group);
            }
            catch (Exception ex)
            {
                ViewBag.Message = "ERROR: " + ex.Message.ToString();
            }
            return(RedirectToAction("Details", new { area = "Admin", id = model.Group.Id }));
        }
        public async Task <ActionResult> Details(Guid id)
        {
            var model = await GroupFacade.GetGroupAsync(id);

            return(View("Details", model));
        }