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));
        }