public IActionResult Edit(HomeEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var employee = new Employee()
         {
             Email      = model.Email,
             Department = model.Department,
             Id         = model.Id,
             Name       = model.Name,
             AvatarPath = model.AvatarPath
         };
         if (model.Photo != null)
         {
             var folderPath     = Path.Combine(webHostEnvironment.WebRootPath, "images");
             var uniqueFileName = $"{Guid.NewGuid()}_{model.Photo.FileName}";
             var filePath       = Path.Combine(folderPath, uniqueFileName);
             using (var fileName = new FileStream(filePath, FileMode.Create))
             {
                 model.Photo.CopyTo(fileName);
             }
             employee.AvatarPath = uniqueFileName;
             if (!string.IsNullOrEmpty(model.AvatarPath))
             {
                 string delFilePath = Path.Combine(webHostEnvironment.WebRootPath, "images", model.AvatarPath);
                 System.IO.File.Delete(delFilePath);
             }
         }
         var editEmp = employeeRepository.Update(employee);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Beispiel #2
0
        public ActionResult Edit(int id)
        {
            var query         = new QuestionnaireById(id);
            var questionnaire = _repository.Find(query);

            if (questionnaire.Status == QuestionnaireStatus.NotStarted)
            {
                questionnaire.Status     = QuestionnaireStatus.InProgress;
                questionnaire.ModifiedBy = User.Identity.Name.ToUpper();
                questionnaire.Modified   = DateTime.Now;
                questionnaire.ModifiedBy = User.Identity.Name.ToUpper();
                questionnaire.Started    = DateTime.Now;
                questionnaire.StartedBy  = User.Identity.Name.ToUpper();

                _repository.Context.Update(questionnaire);
                _repository.Context.Commit();
            }

            var model = new HomeEditViewModel(_repository, questionnaire)
            {
                DisplayLogicDepth = Globals.DisplayLogicDepth
            };

            return(View(model));
        }
Beispiel #3
0
        public IActionResult Edit(int id)
        {
            var product = productRepository.Get(id);

            if (product == null)
            {
                //ViewBag.Id = id;
                return(View("~/Views/Error/ProductNotFound.cshtml", id));
            }
            var ediPro = new HomeEditViewModel()
            {
                Avatar      = product.Avatar,
                Name        = product.Name,
                Brand       = product.Brand,
                Radius      = product.Radius,
                Thickness   = product.Thickness,
                Cord        = product.Cord,
                Glasses     = product.Glasses,
                water_proof = product.water_proof,
                Guarantee   = product.Guarantee,
                Price       = product.Price,
                CategoryId  = product.CategoryId
            };

            return(View(ediPro));
        }
Beispiel #4
0
        public IActionResult Edit(HomeEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                Employee employee = _employeeRepository.GetEmployee(model.Id);

                employee.Name       = model.Name;
                employee.Email      = model.Email;
                employee.Department = model.Department;
                if (model.Photo != null)
                {
                    if (model.ExistingPhotoPath != null)
                    {
                        string filePath = Path.Combine(webHostEnvironment.WebRootPath, "images", model.ExistingPhotoPath);
                        System.IO.File.Delete(filePath);
                    }

                    employee.PhotoPath = ProcessUploadFile(model);
                }

                _employeeRepository.Update(employee);
                return(RedirectToAction("Details", "Home", new { id = employee.Id }));
            }

            return(View());
        }
        public IActionResult Edit(int Id)
        {
            var viewModel = new HomeEditViewModel();
            var dbcat     = _dbContext.ProductCategory.First(p => p.Id == Id);

            viewModel.Id   = dbcat.Id;
            viewModel.Name = dbcat.Name;

            return(View(viewModel));
        }
 public IActionResult Edit(int Id, HomeEditViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var dbcat = _dbContext.ProductCategory.First(p => p.Id == Id);
         dbcat.Id   = viewModel.Id;
         dbcat.Name = viewModel.Name;
         _dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(viewModel));
 }
Beispiel #7
0
        public async Task <IActionResult> Edit(HomeEditViewModel data)
        {
            if (ModelState.IsValid)
            {
                await questionsRepository.Update(new Questions
                {
                    CorrectOption = data.Question.CorrectOption,
                    QuestionId    = data.Question.QuestionId,
                    QuestionText  = data.Question.QuestionText
                });

                List <Options> optionsToUpdate = new List <Options>
                {
                    new Options {
                        OptionsId = data.Option1.OptionsId, OptionText = data.Option1.OptionText, QuestionId = data.Option1.QuestionId
                    },
                    new Options {
                        OptionsId = data.Option2.OptionsId, OptionText = data.Option2.OptionText, QuestionId = data.Option2.QuestionId
                    },
                    new Options {
                        OptionsId = data.Option3.OptionsId, OptionText = data.Option3.OptionText, QuestionId = data.Option3.QuestionId
                    },
                    new Options {
                        OptionsId = data.Option4.OptionsId, OptionText = data.Option4.OptionText, QuestionId = data.Option4.QuestionId
                    }
                };

                optionsRepository.Update(optionsToUpdate);

                return(RedirectToAction("Index"));
            }

            var optionsList = optionsRepository.GetByQuestionId(data.Question.QuestionId);

            data.Options = new List <Option>
            {
                new Option {
                    Id = 1, OptionText = optionsList[0].OptionText
                },
                new Option {
                    Id = 2, OptionText = optionsList[1].OptionText
                },
                new Option {
                    Id = 3, OptionText = optionsList[2].OptionText
                },
                new Option {
                    Id = 4, OptionText = optionsList[3].OptionText
                }
            };

            return(View(data));
        }
        public IActionResult Edit(int id)
        {
            Employee          employee = _employeeRepository.GetEmployee(id);
            HomeEditViewModel model    = new HomeEditViewModel()
            {
                Id                = employee.Id,
                Name              = employee.Name,
                Email             = employee.Email,
                Department        = employee.Department,
                ExistingPhotoPath = employee.PhotoPath
            };

            return(View(model));
        }
        public IActionResult Edit(int id)
        {
            var employee = employeeRepository.Get(id);
            var editEmp  = new HomeEditViewModel()
            {
                AvatarPath = employee.AvatarPatch,
                Name       = employee.Name,
                Email      = employee.Email,
                Department = employee.Department,
                Id         = employee.EmployeeId
            };

            return(View(editEmp));
        }
Beispiel #10
0
        public ViewResult Edit(int?id)
        {
            var employee = employeeRepository.GetEmployee(id ?? 1);
            var editEmp  = new HomeEditViewModel()
            {
                ExistingAvatarPath = employee.AvatarPath,
                Department         = employee.Department,
                Email = employee.Email,
                Id    = employee.Id,
                Name  = employee.Name,
            };

            return(View(editEmp));
        }
Beispiel #11
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            HomeEditViewModel home = this.service.GetHomeEditViewModelById((int)id);

            if (home == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            return(View(home));
        }
        public IActionResult Edit(int id)
        {
            var student     = studentRepository.Get(id);
            var editStudent = new HomeEditViewModel()
            {
                Id       = student.Id,
                Fullname = student.Fullname,
                Gender   = student.Gender,
                DoB      = student.DoB,
                Email    = student.Email,
                ClassId  = student.ClassId
            };

            ViewBag.Classes = GetClasses();
            return(View(editStudent));
        }
Beispiel #13
0
        public IActionResult Edit(HomeEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var product = new Product()
                {
                    Name        = model.Name,
                    Brand       = model.Brand,
                    Radius      = model.Radius,
                    Thickness   = model.Thickness,
                    Cord        = model.Cord,
                    Glasses     = model.Glasses,
                    water_proof = model.water_proof,
                    Guarantee   = model.Guarantee,
                    Price       = model.Price,
                    Id          = model.Id,
                    Avatar      = model.Avatar,
                    CategoryId  = model.CategoryId
                };
                var fileName = string.Empty;
                if (model.AvatarPath != null)
                {
                    string uploadFoder = Path.Combine(webHostEnvironment.WebRootPath, "img");
                    fileName = $"{Guid.NewGuid()}_{ model.AvatarPath.FileName}";
                    var filePath = Path.Combine(uploadFoder, fileName);
                    using (var fs = new FileStream(filePath, FileMode.Create))
                    {
                        model.AvatarPath.CopyTo(fs);
                    }
                    product.Avatar = fileName;

                    if (!string.IsNullOrEmpty(model.Avatar))
                    {
                        string delFile = Path.Combine(webHostEnvironment.WebRootPath, "img", model.Avatar);
                        System.IO.File.Delete(delFile);
                    }
                }


                if (productRepository.Edit(product) != null)
                {
                    return(RedirectToAction("Details", new { id = model.Id }));
                }
            }

            return(View());
        }
 public IActionResult Create(HomeEditViewModel restaurantData)
 {
     if (ModelState.IsValid)
     {
         var restaurant = new Restaurant
         {
             Name    = restaurantData.Name,
             Cuisine = restaurantData.Cuisine
         };
         var newRestaurant = _restaurantData.Add(restaurant);
         return(RedirectToAction("Details", new { id = newRestaurant.Id }));
     }
     else
     {
         return(View());
     }
 }
Beispiel #15
0
        public ViewResult Edit(int id)
        {
            var product = productRepository.Get(id);

            ViewBag.Categories = categoriesRepository.Gets().ToList();
            var editPrd = new HomeEditViewModel()
            {
                ProductPath = product.ProductImage,
                ProductName = product.ProductName,
                Description = product.Description,
                Price       = product.Price,
                Count       = product.Count,
                CategoryId  = product.CategoriesCategoryId,
                Id          = product.ProductId
            };

            return(View(editPrd));
        }
Beispiel #16
0
 public IActionResult Edit(HomeEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var employee = employeeRepository.GetEmployee(model.Id);
         employee.Name       = model.Name;
         employee.Department = model.Department;
         employee.Email      = model.Email;
         employee.AvatarPath = UploadAvatar(model);
         if (model.ExistingAvatarPath != null)
         {
             string filePath = Path.Combine(webHostEnvironment.WebRootPath, "images", model.ExistingAvatarPath);
             System.IO.File.Delete(filePath);
         }
         employeeRepository.Edit(employee);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Beispiel #17
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(View("QuestionNotFound"));
            }

            var question = await questionsRepository.Get(id);//Get the Question

            //redirect to error page if the Question doesn't exist
            if (question == null)
            {
                return(View("QuestionNotFound"));
            }

            var optionsList = optionsRepository.GetByQuestionId(id);

            var viewModel = new HomeEditViewModel
            {
                Question = question,
                Options  = new List <Option>
                {
                    new Option {
                        Id = 1, OptionText = optionsList[0].OptionText
                    },
                    new Option {
                        Id = 2, OptionText = optionsList[1].OptionText
                    },
                    new Option {
                        Id = 3, OptionText = optionsList[2].OptionText
                    },
                    new Option {
                        Id = 4, OptionText = optionsList[3].OptionText
                    }
                },
                Option1 = optionsList[0],
                Option2 = optionsList[1],
                Option3 = optionsList[2],
                Option4 = optionsList[3]
            };

            return(View(viewModel));
        }
Beispiel #18
0
        public ViewResult Edit(int id)
        {
            var flower = flowerRepository.Get(id);

            if (flower == null)
            {
                return(View("~/Views/Error/FlowerNotFound.cshtml", id));
            }
            var empEdit = new HomeEditViewModel()
            {
                AvatarPath = flower.AvatarPath,
                Name       = flower.Name,

                TypeF = flower.TypeF,
                Id    = flower.Id
            };

            return(View(empEdit));
        }
Beispiel #19
0
        public ViewResult Edit(int id)
        {
            var employee = employeeRepository.Get(id);

            if (employee == null)
            {
                return(View("~/Views/Error/EmployeeNotFound.cshtml", id));
            }
            var empEdit = new HomeEditViewModel()
            {
                AvatarPath = employee.AvatarPath,
                Name       = employee.Name,
                Email      = employee.Email,
                Department = employee.Department,
                Id         = employee.Id
            };

            return(View(empEdit));
        }
Beispiel #20
0
        public IActionResult Edit(int id)
        {
            var student     = studentRepository.Get(id);
            var editStudent = new HomeEditViewModel()
            {
                Id = student.Id,

                nameCake  = student.nameCake,
                ThanhPhan = student.ThanhPhan,

                Hsd        = student.Hsd,
                Nsx        = student.Nsx,
                GiaBan     = student.GiaBan,
                DaXoa      = student.DaXoa,
                CategoryId = student.CategoryId
            };

            ViewBag.Category = GetClasses();
            return(View(editStudent));
        }
        public IActionResult Edit(HomeEditViewModel model)
        {
            if (ModelState.IsValid)
            {

                var employee = new Employee()
                {
                    FullName = model.FullName,
                    Email = model.Email,
                    Department = model.Department,
                    Id= model.Id,
                    AvatarPath= model.AvatarPath

                };
                var fileName = string.Empty;
                if (model.Avatar != null)
                {
                    string uploadFolder = Path.Combine(WebHostEnvironment.WebRootPath, "images");
                    fileName = $"{Guid.NewGuid()}_{model.Avatar.FileName}";
                    var filePath = Path.Combine(uploadFolder, fileName);
                    using (var fs = new FileStream(filePath, FileMode.Create))
                    {
                        model.Avatar.CopyTo(fs);
                    }
                    employee.AvatarPath = $"{fileName}";
                    if (!string.IsNullOrEmpty(model.AvatarPath))
                    {
                        string delFile = Path.Combine(WebHostEnvironment.WebRootPath, "images",model.AvatarPath);
                        System.IO.File.Delete(delFile);
                    }
                }
              
                var editEmp = employeeRepository.Edit(employee);
                if (editEmp != null)
                {
                    return RedirectToAction("Index", new { id = employee.Id });
                }
            }
           
            return View();
        }
        public IActionResult Edit()
        {
            var userId = userManager.GetUserId(this.User);

            var home          = this.homes.Find(userId);
            var homeEditModel = new HomeEditViewModel

            {
                Additionalnformation = home.Additionalnformation,
                Address       = home.Address,
                Bathrooms     = home.Bathrooms,
                Bedrooms      = home.Bedrooms,
                City          = home.City,
                Country       = home.Country,
                IsActiveOffer = home.IsActiveOffer,
                PricePerNight = home.PricePerNight,
                Sleeps        = home.Sleeps
            };

            return(this.View(homeEditModel));
        }
        public IActionResult Edit(HomeEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var editStd = new Student()
                {
                    Id       = model.Id,
                    Fullname = model.Fullname,
                    Gender   = model.Gender,
                    DoB      = model.DoB,
                    Email    = model.Email,
                    ClassId  = model.ClassId
                };
                studentRepository.Edit(editStd);


                return(RedirectToAction("ViewDetail", "Home", new { id = editStd.ClassId }));
            }
            ViewBag.Classes = GetClasses();
            return(View());
        }
Beispiel #24
0
        public ViewResult Edit(int id)
        {
            var product = productRepository.Get(id);

            if (product == null)
            {
                return(View("~/Views/Error/ProductNotFound.cshtml", id));
            }
            var prdEdit = new HomeEditViewModel()
            {
                ImagePath       = product.ImagePath,
                ProdName        = product.ProdName,
                Price           = product.Price,
                ProdInformation = product.ProdInformation,
                Id         = product.Id,
                CategoryId = product.CategoryId
            };

            ViewBag.Categories = CategoryRepository.Get().ToList();
            return(View(prdEdit));
        }
Beispiel #25
0
        public IActionResult Edit(HomeEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var flower = new Flower()
                {
                    Name = model.Name,

                    TypeF      = model.TypeF,
                    Id         = model.Id,
                    AvatarPath = model.AvatarPath
                };
                var fileName = string.Empty;
                if (model.Avatar != null)
                {
                    string uploadFolder = Path.Combine(webHostEnvironment.WebRootPath, "images");
                    fileName = $"{Guid.NewGuid()}_{model.Avatar.FileName}";
                    var filePath = Path.Combine(uploadFolder, fileName);
                    using (var fs = new FileStream(filePath, FileMode.Create))
                    {
                        model.Avatar.CopyTo(fs);
                    }
                    flower.AvatarPath = fileName;
                    if (!string.IsNullOrEmpty(model.AvatarPath))
                    {
                        string delFile = Path.Combine(webHostEnvironment.WebRootPath,
                                                      "images", model.AvatarPath);
                        System.IO.File.Delete(delFile);
                    }
                }

                var editEmp = flowerRepository.Edit(flower);
                if (editEmp != null)
                {
                    return(RedirectToAction("Details", new { id = flower.Id }));
                }
            }

            return(View());
        }
Beispiel #26
0
 public IActionResult Edit(HomeEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var product = new Product()
         {
             ImagePath       = model.ImagePath,
             ProdName        = model.ProdName,
             Price           = model.Price,
             ProdInformation = model.ProdInformation,
             Id         = model.Id,
             CategoryId = model.CategoryId
         };
         var fileName = string.Empty;
         if (model.Images != null)
         {
             string uploadFolder = Path.Combine(webHostEnvironment.WebRootPath, "images");
             fileName = $"{Guid.NewGuid()}_{model.Images.FileName}";
             var filePath = Path.Combine(uploadFolder, fileName);
             using (var fs = new FileStream(filePath, FileMode.Create))
             {
                 model.Images.CopyTo(fs);
             }
             product.ImagePath = fileName;
             if (!string.IsNullOrEmpty(model.ImagePath))
             {
                 string delFile = Path.Combine(webHostEnvironment.WebRootPath, "images", model.ImagePath);
                 System.IO.File.Delete(delFile);
             }
         }
         var editEmp = productRepository.Edit(product);
         if (editEmp != null)
         {
             return(RedirectToAction("Index", new { id = product.Id }));
         }
     }
     return(View(model));
 }
Beispiel #27
0
        public IActionResult Edit(int id)
        {
            Tag[] tagsFromDb             = _appContext.Tags.ToArray();
            List <HomeTagViewModel> tags = new List <HomeTagViewModel>();

            Status[] statusesFromDb        = _appContext.Statuses.ToArray();
            List <SelectListItem> statuses = new List <SelectListItem>();

            foreach (var item in statusesFromDb)
            {
                statuses.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(),
                    Text  = item.Naam
                });
            }
            foreach (var item in tagsFromDb)
            {
                tags.Add(new HomeTagViewModel()
                {
                    Id   = item.Id,
                    Name = item.Naam,
                });
            }


            Project           projectFromDb = _appContext.Projects.FirstOrDefault(x => x.Id == id);
            HomeEditViewModel vm            = new HomeEditViewModel()
            {
                Titel        = projectFromDb.Titel,
                Beschrijving = projectFromDb.Beschrijving,
                Foto         = projectFromDb.Foto,
                Tags         = tags,
                Statuses     = statuses
            };

            return(View(vm));
        }
Beispiel #28
0
 public IActionResult Edit(HomeEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var product = new Product()
         {
             ProductName          = model.ProductName,
             Description          = model.Description,
             Price                = model.Price,
             Count                = model.Count,
             CategoriesCategoryId = model.CategoryId,
             ProductId            = model.Id
         };
         var fileName = string.Empty;
         if (model.ProductImage != null)
         {
             string uploadFolder = Path.Combine(webHostEnvironment.WebRootPath, "images");
             fileName = $"{Guid.NewGuid()}_{model.ProductImage.FileName}";
             var filePath = Path.Combine(uploadFolder, fileName);
             using (var fs = new FileStream(filePath, FileMode.Create))
             {
                 model.ProductImage.CopyTo(fs);
             }
             product.ProductImage = fileName;
         }
         else
         {
             product.ProductImage = model.ProductPath;
         }
         var editPrd = productRepository.Edit(product);
         if (editPrd != null)
         {
             return(RedirectToAction("Index", "Product", new { id = product.ProductId }));
         }
     }
     return(View());
 }
Beispiel #29
0
        public IActionResult edit(int id, HomeEditViewModel model)
        {
            if (!TryValidateModel(model))
            {
                return(View(model));
            }
            Tag[] tagsFromDb             = _appContext.Tags.ToArray();
            List <HomeTagViewModel> tags = new List <HomeTagViewModel>();
            Project projectToEdit        = new Project()
            {
                Id           = id,
                Titel        = model.Titel,
                Beschrijving = model.Beschrijving,
                Foto         = model.Foto,
                StatusId     = int.Parse(model.SelectedStatus),
            };

            _appContext.Projects.Update(projectToEdit);
            _appContext.SaveChanges();

            foreach (var item in model.Tags)
            {
                if (item.Checked)
                {
                    var tagProject = new TagProject()
                    {
                        ProjectId = projectToEdit.Id,
                        TagId     = item.Id
                    };
                    _appContext.TagProjects.Update(tagProject);
                    _appContext.SaveChanges();
                }
            }

            return(RedirectToAction("Details", new { Id = id }));
        }
Beispiel #30
0
        public IActionResult Edit(HomeEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var editStd = new Cake()
                {
                    Id        = model.Id,
                    nameCake  = model.nameCake,
                    ThanhPhan = model.ThanhPhan,

                    Hsd        = model.Hsd,
                    Nsx        = model.Nsx,
                    GiaBan     = model.GiaBan,
                    DaXoa      = model.DaXoa,
                    CategoryId = model.CategoryId
                };
                studentRepository.Edit(editStd);


                return(RedirectToAction("ViewDetail", "Home", new { id = editStd.CategoryId }));
            }
            ViewBag.Category = GetClasses();
            return(View());
        }