Exemplo n.º 1
0
        public async Task <ActionResult> Index(Contact contact, string lang)
        {
            var model = new HomePageModel();

            try
            {
                if (ModelState.IsValid)
                {
                    int b = await DbAdaptor.CreateContactAsync(contact);

                    if (b > 0)
                    {
                        //ToDo check int
                        ViewBag.SendMessage = Resources.Resource.Message_sent;
                        ModelState.Clear();
                    }
                }
                model.TeamMembers = await DbAdaptor.GetTeamMembersAsync(cultureName);

                model.Projects = await DbAdaptor.GetProjectsFullAsync(cultureName);
            }
            catch (Exception)
            {
                ViewBag.SendMessage = Resources.Resource.Message_not_sent;
            }
            return(View(model));
        }
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            TeamMember teamMember = await DbAdaptor.GetTeamMemberAsync(id);

            imageId = teamMember.Image?.ImageID;

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

            ViewBag.Lang = new SelectList(new List <SelectListItem> {
                new SelectListItem {
                    Text = "en", Value = "en"
                },
                new SelectListItem {
                    Text = "ru", Value = "ru"
                },
                new SelectListItem {
                    Text = "am", Value = "am"
                },
            },
                                          "Value", "Text");
            return(View(teamMember));
        }
        public async Task <ActionResult> Edit(Technology technology)
        {
            if (ModelState.IsValid)
            {
                await DbAdaptor.EditTechnologyAsync(technology);

                return(RedirectToAction("Index"));
            }
            return(View(technology));
        }
Exemplo n.º 4
0
        public async Task <FileContentResult> GetImage(int imageId)
        {
            Image image = await DbAdaptor.GetImageAsync(imageId);

            if (image != null)
            {
                return(File(image.ImageData, image.ImageMimeType));
            }
            return(null);
        }
Exemplo n.º 5
0
        public async Task <ActionResult> More(int id)
        {
            Project model = await DbAdaptor.GetProjectAsync(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_More", model));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Index()
        {
            var model = new HomePageModel();

            model.TeamMembers = await DbAdaptor.GetTeamMembersAsync(cultureName);

            model.Projects = await DbAdaptor.GetProjectsFullAsync(cultureName);

            ViewBag.SendMessage = "";
            return(View(model));
        }
Exemplo n.º 7
0
        public async Task <ActionResult> More(int id)
        {
            ViewBag.Portfolio = true;

            Project model = await DbAdaptor.GetProjectAsync(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("~/Views/Home/_More.cshtml", model));

            // return RedirectToAction("More", "Home", new { id = id });
        }
        public async Task <ActionResult> Create(Project project, HttpPostedFileBase[] files, int[] TechnologyID)
        {
            if (ModelState.IsValid)
            {
                DbAdaptor     dbAdaptor = new DbAdaptor();
                IList <Image> imageList = new List <Image>();
                Image         img       = null;
                if (files != null)
                {
                    foreach (var file in files)
                    {
                        img = new Image {
                            ImageData = new byte[file.ContentLength], ImageMimeType = file.ContentType,
                        };
                        file.InputStream.Read(img.ImageData, 0, file.ContentLength);
                        imageList.Add(img);
                    }
                }
                int projectId = await DbAdaptor.CreateProjectAsync(new Project
                {
                    Name        = project.Name,
                    Description = project.Description,
                    Images      = imageList,
                    Lang        = project.Lang,
                });

                foreach (var elem in TechnologyID)
                {
                    await DbAdaptor.CreateProjectTechnologyAsync(new ProjectTechnology
                    {
                        ProjectID    = projectId,
                        TechnologyID = elem,
                    });
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.Lang = new SelectList(new List <SelectListItem> {
                new SelectListItem {
                    Text = "en", Value = "en"
                },
                new SelectListItem {
                    Text = "ru", Value = "ru"
                },
                new SelectListItem {
                    Text = "am", Value = "am"
                },
            },
                                          "Value", "Text");
            return(View(project));
        }
        public async Task <ActionResult> Edit(Project project, HttpPostedFileBase[] files, int[] TechnologyID)
        {
            if (ModelState.IsValid)
            {
                DbAdaptor dbAdaptor = new DbAdaptor();
                Image     img       = null;
                foreach (var file in files)
                {
                    if (file != null)
                    {
                        img = new Image {
                            ImageData = new byte[file.ContentLength], ImageMimeType = file.ContentType,
                        };
                        file.InputStream.Read(img.ImageData, 0, file.ContentLength);
                        img.ProjectID = project.ProjectID;
                        await DbAdaptor.CreateImageAsync(img);
                    }
                }

                if (TechnologyID != null)
                {
                    foreach (var elem in TechnologyID)
                    {
                        await DbAdaptor.CreateProjectTechnologyAsync(new ProjectTechnology
                        {
                            ProjectID    = project.ProjectID,
                            TechnologyID = elem,
                        });
                    }
                }

                await DbAdaptor.EditProjectAsync(project);

                return(RedirectToAction("Index"));
            }

            ViewBag.Lang = new SelectList(new List <SelectListItem> {
                new SelectListItem {
                    Text = "en", Value = "en"
                },
                new SelectListItem {
                    Text = "ru", Value = "ru"
                },
                new SelectListItem {
                    Text = "am", Value = "am"
                },
            },
                                          "Value", "Text");
            return(View(project));
        }
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            TeamMember teamMember = await DbAdaptor.GetTeamMemberAsync(id);

            if (teamMember == null)
            {
                return(HttpNotFound());
            }
            return(View(teamMember));
        }
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Project project = await DbAdaptor.GetProjectAsync(id);

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

            return(View(project));
        }
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Technology technology = await DbAdaptor.GetTechnologyAsync(id);

            if (technology == null)
            {
                return(HttpNotFound());
            }
            return(View(technology));
        }
        public async Task <ActionResult> DeleteImage(TeamMember teamMember, int imgDeleteID)
        {
            await DbAdaptor.EditTeamMemberAsync(new TeamMember
            {
                TeamMemberID = teamMember.TeamMemberID,
                Firstname    = teamMember.Firstname,
                Lastname     = teamMember.Lastname,
                Lang         = teamMember.Lang,
                Position     = teamMember.Position,
                ImageId      = null,
            });

            await DbAdaptor.DeleteTeamMemberAsync(imgDeleteID);

            return(RedirectToAction("Edit", "TeamMembers", new { id = teamMember.TeamMemberID }));
        }
        public async Task <ActionResult> Edit(TeamMember teamMember, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                TeamMember teamMemberEdit = new TeamMember
                {
                    TeamMemberID = teamMember.TeamMemberID,
                    Firstname    = teamMember.Firstname,
                    Lastname     = teamMember.Lastname,
                    Position     = teamMember.Position,
                    Lang         = teamMember.Lang,
                };
                if (file != null)
                {
                    var img = new Image {
                        ImageData = new byte[file.ContentLength], ImageMimeType = file.ContentType,
                    };
                    file.InputStream.Read(img.ImageData, 0, file.ContentLength);
                    teamMemberEdit.ImageId = await DbAdaptor.CreateImageAsync(img);
                }
                else
                {
                    teamMemberEdit.ImageId = imageId;
                }


                await DbAdaptor.EditTeamMemberAsync(teamMemberEdit);

                return(RedirectToAction("Index"));
            }

            ViewBag.Lang = new SelectList(new List <SelectListItem> {
                new SelectListItem {
                    Text = "en", Value = "en"
                },
                new SelectListItem {
                    Text = "ru", Value = "ru"
                },
                new SelectListItem {
                    Text = "am", Value = "am"
                },
            },
                                          "Value", "Text");
            return(View(teamMember));
        }
        public async Task <ActionResult> Create()
        {
            ViewBag.Lang = new SelectList(new List <SelectListItem> {
                new SelectListItem {
                    Text = "en", Value = "en"
                },
                new SelectListItem {
                    Text = "ru", Value = "ru"
                },
                new SelectListItem {
                    Text = "am", Value = "am"
                },
            },
                                          "Value", "Text");
            IList <Technology> technologies = await DbAdaptor.GetTechnologiesAsync();

            ViewBag.TechnologyID = new MultiSelectList(technologies, "TechnologyID", "Name");
            return(View());
        }
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Project project = await DbAdaptor.GetProjectAsync(id);

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

            ViewBag.Lang = new SelectList(new List <SelectListItem> {
                new SelectListItem {
                    Text = "en", Value = "en"
                },
                new SelectListItem {
                    Text = "ru", Value = "ru"
                },
                new SelectListItem {
                    Text = "am", Value = "am"
                },
            },
                                          "Value", "Text");

            var all = await DbAdaptor.GetTechnologiesAsync();

            var selected = project.Technologies?.ToList();

            if (selected != null)
            {
                var notSelected = all.Where(x => !selected.Contains(x)).ToList();
                ViewBag.TechnologyID = notSelected.Count > 0 ?  new MultiSelectList(notSelected, "TechnologyID", "Name") : null;
            }
            return(View(project));
        }
Exemplo n.º 17
0
        public async Task <ActionResult> Index()
        {
            var team = await DbAdaptor.GetTeamMembersAsync(cultureName);

            return(View(team));
        }
        public async Task <ActionResult> DeleteTechnology(Project project, int techDeleteID)
        {
            await DbAdaptor.DeleteProjectTechnologyAsync(project.ProjectID, techDeleteID);

            return(RedirectToAction("Edit", "Projects", new { id = project.ProjectID }));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            await DbAdaptor.DeleteProjectAsync(id);

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Index()
        {
            IList <Technology> list = await DbAdaptor.GetTechnologiesAsync();

            return(View(list));
        }
        public async Task <ActionResult> Index()
        {
            var contact = await DbAdaptor.GetContactsAsync();

            return(View());
        }
        public async Task <ActionResult> DeleteImage(Project project, int imgDeleteID)
        {
            await DbAdaptor.DeleteImageAsync(imgDeleteID);

            return(RedirectToAction("Edit", "Projects", new { id = project.ProjectID }));
        }
        public async Task <ActionResult> Index()
        {
            IList <Project> list = await DbAdaptor.GetProjectsAsync();

            return(View(list));
        }
        public async Task <ActionResult> Index()
        {
            IList <TeamMember> list = await DbAdaptor.GetTeamMembersAsync();

            return(View(list));
        }