Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit(Guid id)
        {
            var group = await GroupFacade.GetGroupAsync(id);

            return(View("Edit", new GroupImageModel {
                Group = group, File = null
            }));
        }
Ejemplo n.º 3
0
        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"));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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 }));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Details(Guid id)
        {
            var model = await GroupFacade.GetGroupAsync(id);

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