public ActionResult CreateUser()
        {
            var viewmodel = new  WorkshopViewModel();

            viewmodel.roles = db.Roles.ToList();
            return(View(viewmodel));
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var slug = (string)ControllerContext.RouteData.Values["slug"];

            if (!string.IsNullOrEmpty(slug))
            {
                Workshop = filterService.FindBySlug(slug);
                if (Workshop == null)
                {
                    filterContext.Result = new UnauthorizedResult();
                }

                /*
                 * if (Workshop != null)
                 * {
                 *  var accessCode = (string)ControllerContext.RouteData.Values["accessCode"];
                 *
                 *  if (accessCode == null || !string.Equals(accessCode, this.Workshop.AccessCode, StringComparison.Ordinal))
                 *  {
                 *      filterContext.Result = new UnauthorizedResult();
                 *  }
                 * }
                 */
            }

            base.OnActionExecuting(filterContext);
        }
        public async Task <IActionResult> WorkshopSetting()
        {
            try
            {
                var userID = _httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);

                var workshop = await _context.WorkShops
                               .Include(w => w.User)
                               .Include(w => w.City)
                               .Include(w => w.City.Government)
                               .FirstOrDefaultAsync(w => w.User.Id == userID);

                ViewBag.Verified = workshop.Verified;


                var viewModel = new WorkshopViewModel
                {
                    Id         = workshop.Id,
                    Name       = workshop.Name,
                    ImageUrl   = workshop.Image,
                    LogoeUrl   = workshop.Logo,
                    Address    = workshop.Address,
                    City       = workshop.City.Name,
                    Government = workshop.City.Government.Name,
                    UserId     = workshop.UserId,
                    User       = workshop.User,
                };
                return(View(viewModel));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }
Esempio n. 4
0
        public ActionResult UpdateWorkshop(WorkshopViewModel workshop, FormCollection form)
        {
            var userId = User.Identity.GetUserId();
            var work   = _context.Workshops.Single(w => w.Id == workshop.Id && w.TalentedId == userId);

            work.workshop_Name        = workshop.workshop_Name;
            work.workshop_Location    = workshop.workshop_Location;
            work.workshop_Date        = workshop.workshop_Date.Date;
            work.workshop_Fees        = workshop.workshop_Fees;
            work.workshop_Sessions    = workshop.workshop_Sessions;
            work.workshop_Description = workshop.workshop_Description;
            work.DateTime             = DateTime.Now;
            _context.SaveChanges();

            string SelectVal = form["SelectVal"];

            string[] FavIds = SelectVal.Split(',');



            WorkshopUserTable fav = new WorkshopUserTable();

            for (int i = 0; i < FavIds.Length; i++)
            {
                var id = int.Parse(FavIds[i]);

                fav.Tagsid     = id;
                fav.Userid     = User.Identity.GetUserId();
                fav.Workshopid = work.Id;


                _context.SaveChanges();
            }
            return(RedirectToAction("AddWorkshop", "TalentedUser"));
        }
        // GET: Workshops/Edit/5
        public ActionResult Edit(int id)
        {
            var workshop            = workshopService.GetWorkshopById(id);
            WorkshopViewModel model = new WorkshopViewModel();

            model.InjectFrom(workshop);
            return(View(model));
        }
Esempio n. 6
0
        // GET: Workshops/Details/5
        public ActionResult Details(int id)
        {
            Workshops         workshops = workshopService.GetWorkshopById(id);
            WorkshopViewModel model     = new WorkshopViewModel();

            model.InjectFrom(workshops);
            return(View(workshops));
        }
Esempio n. 7
0
        // GET: Workshop/Details/5
        public ActionResult Details(int id)
        {
            var getWorkshopById     = workshop.GetById(id);
            WorkshopViewModel model = new WorkshopViewModel();

            model.InjectFrom(getWorkshopById);
            return(View(model));
        }
        public ActionResult Edit(int id, WorkshopViewModel model)
        {
            Workshops workshop = new Workshops();

            workshop.InjectFrom(model);
            var workshopToUpdate = workshopService.UpdateWorkshop(workshop);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 9
0
        public ActionResult Edit(int id, WorkshopViewModel model)
        {
            Workshops edit = new Workshops();

            edit.InjectFrom(model);
            var createNewWorkshop = workshop.Update(edit);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 10
0
        // GET: Workshops/Edit/5
        public ActionResult Edit(int id)
        {
            var edit = workshop.GetById(id);
            WorkshopViewModel model = new WorkshopViewModel();

            model.InjectFrom(edit);

            return(View(model));
        }
Esempio n. 11
0
        public ActionResult DisplayWorkshop()
        {
            var userId             = User.Identity.GetUserId();
            WorkshopViewModel work = new WorkshopViewModel();

            work.Workshop     = _context.Workshops.Include("Talented").Where(w => w.TalentedId == userId).ToList();
            work.Tags         = _context.Tags.ToList();
            work.WorkshopTags = _context.WorkshopUserTable.ToList();
            return(View(work));
        }
        public ActionResult Delete(int id, WorkshopViewModel model)
        {
            Workshops workshopToDelete = new Workshops();

            workshopToDelete = workshopService.GetWorkshopById(id);
            model.InjectFrom(workshopToDelete);
            workshopService.Delete(workshopToDelete);
            workshopService.Save();
            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 13
0
        // GET: Workshops/Delete/5
        public ActionResult Delete(int id)
        {
            var delete = workshop.GetById(id);

            WorkshopViewModel model = new WorkshopViewModel();

            model.InjectFrom(delete);

            return(View(model));
        }
        // GET: Workshop/Delete/5
        public ActionResult Delete(int id)
        {
            var deleteWorkshop = workShopService.GetWorkshopsById(id);

            WorkshopViewModel model = new WorkshopViewModel();

            model.InjectFrom(deleteWorkshop);

            return(View(model));
        }
        public ActionResult Delete(int id, WorkshopViewModel model)
        {
            Workshops deleteWorkshop = new Workshops();

            deleteWorkshop = workShopService.GetWorkshopsById(id);

            model.InjectFrom(deleteWorkshop);

            workShopService.DeleteAWorkshop(deleteWorkshop);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 16
0
        /// <summary>
        /// Gets workshop by Id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public WorkshopViewModel Get(int id)
        {
            var workshopViewModel = new WorkshopViewModel();

            var workshop = _workshopRepo.Get(id);

            if (workshop != null)
            {
                workshopViewModel = _mapper.Map <WorkshopViewModel>(workshop);
            }

            return(workshopViewModel);
        }
Esempio n. 17
0
        public ActionResult Create(WorkshopViewModel model)
        {
            if (ModelState.IsValid)
            {
                Workshops newWorkshop = new Workshops();
                newWorkshop.InjectFrom(model);

                var createWorkshop = workshop.CreateWorkshops(newWorkshop);
                if (createWorkshop == null)
                {
                    ModelState.AddModelError("CompanyName", "Must be unique");
                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult Create(WorkshopViewModel model)
        {
            if (ModelState.IsValid)
            {
                Workshops workshop = new Workshops();
                workshop.InjectFrom(model);
                var createNewWorkshop = workshopService.AddWorkshop(workshop);
                if (createNewWorkshop == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique!");

                    return(View(model));
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 19
0
        /// <summary>
        /// Gets workshop along with all related entities: Project, Employee, Provider Code
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public WorkshopViewModel GetDetails(int id)
        {
            var workshopViewModel = new WorkshopViewModel();

            var workshop = _workshopRepo.GetDetails(id);

            if (workshop != null)
            {
                workshopViewModel              = _mapper.Map <WorkshopViewModel>(workshop);
                workshopViewModel.Project      = _mapper.Map <ProjectViewModel>(workshop.Project);
                workshopViewModel.Employee     = _mapper.Map <EmployeeViewModel>(workshop.Employee);
                workshopViewModel.ProviderCode = _mapper.Map <ProviderCodeViewModel>(
                    workshop.ProviderCode);
            }

            return(workshopViewModel);
        }
Esempio n. 20
0
        public ActionResult EditWorkshop(int id)
        {
            var userId = User.Identity.GetUserId();
            var work   = _context.Workshops.Single(w => w.Id == id && w.TalentedId == userId);

            var viewmodel = new WorkshopViewModel
            {
                Id                   = work.Id,
                workshop_Name        = work.workshop_Name,
                workshop_Date        = work.workshop_Date.Date,
                workshop_Description = work.workshop_Description,
                workshop_Fees        = work.workshop_Fees,
                workshop_Location    = work.workshop_Location,
                workshop_Sessions    = work.workshop_Sessions
            };

            return(View(viewmodel));
        }
Esempio n. 21
0
        public ActionResult AddWorkshop(WorkshopViewModel Workshop, FormCollection form)
        {
            // var userid = User.Identity.GetUserId();
            // var tal = _context.TalentedUser.Single(w => w.TalentedId == userid);

            var viewmodel = new Workshops
            {
                TalentedId = User.Identity.GetUserId(),

                workshop_Name        = Workshop.workshop_Name,
                workshop_Date        = Workshop.workshop_Date.Date,
                workshop_Fees        = Workshop.workshop_Fees,
                workshop_Location    = Workshop.workshop_Location,
                workshop_Description = Workshop.workshop_Description,
                workshop_Sessions    = Workshop.workshop_Sessions,
                DateTime             = DateTime.Now
            };

            _context.Workshops.Add(viewmodel);
            _context.SaveChanges();



            string SelectVal = form["SelectVal"];

            string[] FavIds = SelectVal.Split(',');



            WorkshopUserTable fav = new WorkshopUserTable();

            for (int i = 0; i < FavIds.Length; i++)
            {
                var id = int.Parse(FavIds[i]);

                fav.Tagsid     = id;
                fav.Userid     = User.Identity.GetUserId();
                fav.Workshopid = viewmodel.Id;

                _context.WorkshopUserTable.Add(fav);
                _context.SaveChanges();
            }
            return(RedirectToAction("AddWorkshop", "TalentedUser"));
        }
        public ActionResult Edit(int id, WorkshopViewModel model)
        {
            if (ModelState.IsValid)
            {
                Workshops workshops = new Workshops();
                workshops.InjectFrom(model);
                var updateWorkshop = workShopService.UpdateAWorkshop(workshops);

                if (updateWorkshop == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }
 public ActionResult Create(WorkshopViewModel model)
 {
     return(View());
 }
 public ActionResult Delete(int id, WorkshopViewModel model)
 {
     return(View());
 }
 private void Workshop_BtnClicked(object sender, RoutedEventArgs e)
 {
     DataContext = new WorkshopViewModel();
 }
Esempio n. 26
0
        public JsonResult Save(WorkshopViewModel model)
        {
            Response response;

            try
            {
                int    status  = 200;
                string message = string.Empty;
                using (var db = new KiaGalleryContext())
                {
                    if (string.IsNullOrEmpty(model.name))
                    {
                        status  = 500;
                        message = "وارد کردن نام کارگاه اجباری است.";
                    }
                    else
                    {
                        if (model.id != null && model.id > 0)
                        {
                            var entity = db.Workshop.Single(x => x.Id == model.id);
                            entity.Order        = model.order;
                            entity.Alias        = model.alias.Trim();
                            entity.Name         = model.name.Trim();
                            entity.Color        = model.color.Trim();
                            entity.AutoConfirm  = model.autoConfirm;
                            entity.Active       = model.active;
                            entity.GoldTrade    = model.goldTrade;
                            entity.ModifyUserId = GetAuthenticatedUserId();
                            entity.ModifyDate   = DateTime.Now;
                            entity.Ip           = Request.UserHostAddress;

                            message = "کارگاه با موفقیت ویرایش شد.";
                        }
                        else
                        {
                            var entity = new Workshop()
                            {
                                Order        = model.order,
                                Alias        = model.alias.Trim(),
                                Name         = model.name.Trim(),
                                Color        = model.color.Trim(),
                                AutoConfirm  = model.autoConfirm,
                                Active       = model.active,
                                GoldTrade    = model.goldTrade,
                                CreateUserId = GetAuthenticatedUserId(),
                                ModifyUserId = GetAuthenticatedUserId(),
                                CreateDate   = DateTime.Now,
                                ModifyDate   = DateTime.Now,
                                Ip           = Request.UserHostAddress
                            };

                            db.Workshop.Add(entity);
                            message = "کارگاه با موفقیت ایجاد شد.";
                        }
                        db.SaveChanges();
                    }
                }

                response = new Response()
                {
                    status  = status,
                    message = message
                };
            }
            catch (Exception ex)
            {
                response = Core.GetExceptionResponse(ex);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public IActionResult WorkshopSetting(WorkshopViewModel workshopViewModel)
        {
            var workshop = _context.WorkShops.Find(workshopViewModel.Id);

            string uploads        = Path.Combine(hosting.WebRootPath, "Upload/Images");
            string FileName       = null;
            string FullPath       = null;
            string uniqueFileName = null;

            try
            {
                if (workshopViewModel.Imagepath != null)
                {
                    FileName       = workshopViewModel.Imagepath.FileName;
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + FileName;

                    FullPath = Path.Combine(uploads, uniqueFileName);

                    FileInfo file = new(FullPath);

                    workshopViewModel.Imagepath.CopyTo(new FileStream(FullPath, FileMode.Create));

                    if (workshop.Image != null)
                    {
                        System.IO.File.Delete(Path.Combine(uploads, workshop.Image));
                    }

                    workshop.Image = FileName;
                }
                else
                {
                    if (workshopViewModel.RemoveImage == "true")
                    {
                        if (workshop.Image != null)
                        {
                            System.IO.File.Delete(Path.Combine(uploads, workshop.Image));
                        }

                        workshop.Image = null;
                    }
                }

                if (workshopViewModel.Logopath != null)
                {
                    FileName       = workshopViewModel.Logopath.FileName;
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + FileName;

                    FullPath = Path.Combine(uploads, uniqueFileName);

                    FileInfo file = new(FullPath);

                    workshopViewModel.Logopath.CopyTo(new FileStream(FullPath, FileMode.Create));

                    if (workshop.Logo != null)
                    {
                        System.IO.File.Delete(Path.Combine(uploads, workshop.Logo));
                    }

                    workshop.Logo = FileName;
                }
                else
                {
                    if (workshopViewModel.RemoveLogo == "true")
                    {
                        if (workshop.Logo != null)
                        {
                            System.IO.File.Delete(Path.Combine(uploads, workshop.Logo));
                        }

                        workshop.Logo = null;
                    }
                }

                workshop.Name    = workshopViewModel.Name;
                workshop.Address = workshopViewModel.Address;

                var government = _context.Governments.Where(g => g.Name == workshopViewModel.Government).FirstOrDefault();
                workshop.City = _context.Cities
                                .Where(c => c.Name == workshopViewModel.City && c.GovernmentId == government.Id)
                                .FirstOrDefault();

                _context.Update(workshop);
                _context.SaveChanges();

                TempData["Done"] = "Updated Sucessfully";
            }
            catch (Exception)
            {
                TempData["Done"] = "Can't update workshop information, something went wrong";
            }

            return(RedirectToAction(nameof(WorkshopSetting)));
        }
Esempio n. 28
0
 public NewWorkshopView()
 {
     InitializeComponent();
     DataContext = new WorkshopViewModel();
 }