コード例 #1
0
        private async Task LoadAsync(List <EditJobViewModel> jobs, ApplicationUser user)
        {
            user.UserJobs.Select(x => x.UserId);
            foreach (var job in jobs)
            {
                var id          = job.Id;
                var publishedOn = job.PublishedOn;
                var position    = job.Position;
                var employer    = job.Employer;
                var type        = job.EmploymentType;
                var description = job.Description;
                var location    = job.Location;
                var seniority   = job.SeniorityLevel;
                var userIds     = job.UserIds;
                var applied     = job.Applied;
                var saved       = job.Saved;

                var userJob = new EditJobViewModel
                {
                    Id             = id,
                    PublishedOn    = publishedOn,
                    Position       = position,
                    Employer       = employer,
                    EmploymentType = type,
                    Description    = description,
                    Location       = location,
                    SeniorityLevel = seniority,
                    UserIds        = userIds,
                    Applied        = applied,
                    Saved          = saved
                };

                Input.Add(userJob);
            }
        }
コード例 #2
0
        // GET: AdminController/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            var job = this.jobsService.GetJobInfo((Guid)id, null);

            if (job == null)
            {
                return(this.NotFound());
            }
            var viewModel = new EditJobViewModel
            {
                Id          = job.Id,
                Position    = job.Position,
                Employer    = job.Employer,
                Location    = job.Location,
                Description = job.Description,
                Salary      = job.Salary,
                //Keywords = job.Keywords,
                Industry       = job.SubIndustry,
                EmploymentType = job.EmploymentType,
                SeniorityLevel = job.SeniorityLevel
            };

            return(this.View(viewModel));
        }
コード例 #3
0
ファイル: EditJobPage.xaml.cs プロジェクト: ivNetAdmin/iDigIt
 protected override void OnAppearing()
 {
     base.OnAppearing();
     if (BindingContext == null)
     {
         BindingContext = new EditJobViewModel(Navigation, _jobId);
     }
 }
コード例 #4
0
        public ActionResult EditJob(int Id)
        {
            var job   = _jobService.GetById(Id);
            var model = new EditJobViewModel
            {
                Job    = job,
                Users  = _userService.GetAll(),
                Status = _statusService.GetAll()
            };

            return(View(model));
        }
コード例 #5
0
        public async Task <IActionResult> EditJob(EditJobViewModel input)
        {
            await this.jobService.EditJob(
                input.Id,
                input.CompanyEmail,
                input.JobTitle,
                input.JobCategory,
                input.LocationCity,
                input.JobType,
                input.Description);

            return(this.RedirectToAction("Index"));
        }
コード例 #6
0
        public ActionResult Manage(EditJobViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Instantiate our new player with only the Id and Name properties
                Job job = new Job
                {
                    JobId = Guid.NewGuid(),
                    Name  = model.Name
                };

                if (model.WorkerIds != null)
                {
                    foreach (var id in model.WorkerIds)
                    {
                        // Convert the id to a Guid from a string
                        var workerId = Guid.Parse(id);
                        // Retrieve team from database...
                        var worker = db.SYSUsers.Find(workerId);
                        // ... and add it to the player's Team collection
                        try
                        {
                            //  worker.Jobs.Add(job);
                        }
                        catch (Exception ex)
                        {
                            return(View("Error", new HandleErrorInfo(ex, "Jobs", "Index")));
                        }
                    }
                }
                // Add new Player to db & save changes
                try
                {
                    //   db.JOBs.Add(job);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(View("Error", new HandleErrorInfo(ex, "Jobs", "Index")));
                }

                // If successful, return
                return(RedirectToAction("Details", new { id = job.JobId }));
            }
            else
            {
                ModelState.AddModelError("", "Something failed.");
                return(View(model));
            }
        }
コード例 #7
0
        // GET: Customers/{id}/Cars/{carId}/Jobs/Edit/{jobId}
        public ActionResult Edit(int customerId, int carId, int jobId)
        {
            var currentUser = manager.FindById(User.Identity.GetUserId());
            var customer    = customersRepo.GetCustomerById(customerId);
            var car         = carsRepo.GetCarById(carId);
            var job         = jobsRepo.GetJobById(customerId, carId, jobId);

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

            if (car.User != currentUser || job.User != currentUser ||
                customer.User != currentUser)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            if (car.Customer != customer || job.Car != car)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var editJobViewModel = new EditJobViewModel()
            {
                Description = job.Description,
                Mileage     = job.Mileage,
                Paid        = job.IsPaid,
                Finished    = job.IsFinished,
                SpareParts  = job.SpareParts.Select(sp => new EditSparePartViewModel()
                {
                    SparePartId = sp.SparePartId,
                    Name        = sp.Name,
                    Code        = sp.Code,
                    Price       = sp.Price,
                    Quantity    = sp.Quantity,
                    Suppliers   = new UserSuppliersViewModel()
                    {
                        UserSuppliers      = GetUserSuppliers(),
                        SelectedSupplierId = sp.Supplier.SupplierId
                    }
                }).ToList()
            };

            return(View(editJobViewModel));
        }
コード例 #8
0
        public ActionResult Edit([Bind(Include = "JobId,CollectionId,Type,Name,AppKey,Process,Description,CronExpression,JobUrl,ProcessResult,SendSummary,Created,Updated,Status")] EditJobViewModel jobViewModel)
        {
            try
            {
                using (var ctx = new SchedulerDbContext())
                {
                    // Get existing job from db
                    var job = ctx.Jobs.Where(j => j.JobId == jobViewModel.JobId).FirstOrDefault();

                    job.Type           = jobViewModel.Type;
                    job.Name           = jobViewModel.Name;
                    job.CronExpression = jobViewModel.CronExpression;
                    job.AppKey         = jobViewModel.AppKey;
                    job.Process        = jobViewModel.Process;
                    job.Description    = jobViewModel.Description;
                    job.JobUrl         = jobViewModel.JobUrl;
                    job.Status         = jobViewModel.Status;

                    //Get tenantId
                    var tenantID = ctx.Collections.Where(t => t.CollectionId == jobViewModel.CollectionId).FirstOrDefault().TenantId;

                    if (User.IsInRole("SystemAdministrator") || tenantID == CurrentTenant.TenantId)
                    {
                        if (ModelState.IsValid)
                        {
                            ctx.Entry(job).State = EntityState.Modified;
                            ctx.SaveChanges();
                            return(RedirectToAction("Index"));
                        }
                        ViewBag.CollectionId = new SelectList(ctx.Collections.ToList(), "CollectionId", "Name", job.CollectionId);
                    }
                    else
                    {
                        return(View("Authorize"));
                    }
                }
            }

            catch (Exception ex)
            {
                LogService.Info("Jobs not found", ex.Message, ex.InnerException);
            }


            return(View(jobViewModel));
        }
コード例 #9
0
ファイル: JobsController.cs プロジェクト: TsvetiZlateva/wBees
        public async Task <IActionResult> JobsInfo(Guid id)
        {
            ApplicationUser user = await this.userManager.GetUserAsync(this.User);

            var job       = this.jobsService.GetJobInfo(id, user?.Id);
            var viewModel = new EditJobViewModel
            {
                Id          = job.Id,
                Position    = job.Position,
                Employer    = job.Employer,
                Location    = job.Location,
                Description = job.Description,
                Salary      = job.Salary,
                //Keywords = job.Keywords,
                Industry       = job.SubIndustry,
                EmploymentType = job.EmploymentType,
                SeniorityLevel = job.SeniorityLevel,
                Applied        = job.Applied,
                Saved          = job.Saved
            };

            return(this.View(viewModel));
        }
コード例 #10
0
        public ActionResult Edit(EditJobViewModel editJobModel)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Skills = GetCategories();
                return(View(editJobModel));
            }

            EditJobParams editJobParams = new EditJobParams()
            {
                JobId          = editJobModel.JobId,
                SkillsId       = editJobModel.SelectedSkills,
                Title          = editJobModel.Title,
                Description    = editJobModel.Description,
                Price          = editJobModel.Price,
                PriceDiscussed = editJobModel.PriceDiscussed
            };

            _jobService.Edit(editJobParams);
            _commitProvider.SaveChanges();

            return(RedirectToAction("Jobs"));
        }
コード例 #11
0
        public ActionResult Edit(int id)
        {
            JobInfo job = _jobService.FindJob(id);

            if (job == null)
            {
                return(View("Error"));
            }

            EditJobViewModel editJobModel = new EditJobViewModel()
            {
                JobId          = job.Id,
                Title          = job.Title,
                Description    = job.Description,
                Price          = job.Price,
                PriceDiscussed = job.PriceDiscussed
            };

            editJobModel.SelectedSkills = job.Skills.Select(p => p.Id);
            ViewBag.Skills = GetCategories();

            return(View(editJobModel));
        }
コード例 #12
0
        public async Task <IActionResult> EditJob(EditJobViewModel model)
        {
            await this.jobsService.EditAsync(model.Id, model.Level, model.Location, model.Level, model.Engagement, model.Salary);

            return(this.Redirect("/Employer/Dashboard/"));
        }
コード例 #13
0
 public EditJobPage(object owner)
 {
     InitializeComponent();
     editJobViewModel = new EditJobViewModel(owner);
     BindingContext   = editJobViewModel;
 }
コード例 #14
0
        public ActionResult Edit(EditJobViewModel viewModel, int customerId, int carId, int jobId)
        {
            var currentUser = manager.FindById(User.Identity.GetUserId());
            var customer    = customersRepo.GetCustomerById(customerId);
            var car         = carsRepo.GetCarByCustomerId(customerId, carId);

            if (ModelState.IsValid)
            {
                var job = jobsRepo.GetJobById(customerId, carId, jobId);
                job.Mileage      = viewModel.Mileage;
                job.Description  = viewModel.Description;
                job.LastModified = DateTime.Now;
                job.IsPaid       = viewModel.Paid;
                job.IsFinished   = viewModel.Finished;

                /// If the view model spare parts list is empty, we must initialize it,
                /// because the Model Binder assumes it is null by default.
                viewModel.SpareParts = viewModel.SpareParts ?? new List <EditSparePartViewModel>();

                /// Finding all the removed parts during the edit (if any)
                List <int> toBeDeletedIds = new List <int>();
                foreach (var sparePart in job.SpareParts)
                {
                    var existingSparePart = viewModel.SpareParts
                                            .Where(sp => sp.SparePartId == sparePart.SparePartId)
                                            .SingleOrDefault();
                    if (existingSparePart == null)
                    {
                        toBeDeletedIds.Add(sparePart.SparePartId);
                    }
                }

                /// Deleting all the removed parts (if any) from the DB and the entity
                toBeDeletedIds.ForEach(id => sparePartsRepo.DeleteSparePart(id));
                sparePartsRepo.Save();
                job.SpareParts.RemoveAll(x => toBeDeletedIds.Contains(x.SparePartId));

                job.SpareParts.OrderBy(x => x.SparePartId).ToList();
                viewModel.SpareParts.OrderBy(x => x.SparePartId).ToList();


                // if the viewmodel contains more spare parts than the current job
                // add new empty entries to the spare parts list
                int elementsDifference = viewModel.SpareParts.Count - job.SpareParts.Count;
                for (int i = 0; i < elementsDifference; i++)
                {
                    job.SpareParts.Add(new SparePart());
                }

                // copy viewmodel data into the job entity
                for (int i = 0; i < viewModel.SpareParts.Count; i++)
                {
                    job.SpareParts[i].Name     = viewModel.SpareParts[i].Name;
                    job.SpareParts[i].Code     = viewModel.SpareParts[i].Code;
                    job.SpareParts[i].Price    = viewModel.SpareParts[i].Price;
                    job.SpareParts[i].Quantity = viewModel.SpareParts[i].Quantity;
                    job.SpareParts[i].Supplier = suppliersRepo.GetSupplierById(
                        viewModel.SpareParts[i].Suppliers.SelectedSupplierId);
                }

                jobsRepo.UpdateJob(job);
                jobsRepo.Save();
                return(RedirectToAction("Details", new { customerId = customerId, carId = carId, jobId = jobId }));
            }

            return(View(viewModel));
        }
コード例 #15
0
 public EditJobPage()
 {
     InitializeComponent();
     _viewModel  = new EditJobViewModel();
     DataContext = _viewModel;
 }
コード例 #16
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            //Create the model
            var model = new EditJobViewModel();
            var job   = new Job();

            try
            {
                using (var ctx = new SchedulerDbContext())
                {
                    //Get the job from db
                    job = ctx.Jobs.Find(id);

                    ViewBag.CollectionId = new SelectList(ctx.Collections.ToList(), "CollectionId", "Name", job.CollectionId);

                    //Add job to model
                    model.JobId          = job.JobId;
                    model.CollectionId   = job.CollectionId;
                    model.Type           = job.Type;
                    model.Name           = job.Name;
                    model.AppKey         = job.AppKey;
                    model.Process        = job.Process;
                    model.Description    = job.Description;
                    model.CronExpression = job.CronExpression;
                    model.JobUrl         = job.JobUrl;
                    model.ProcessResult  = job.ProcessResult;
                    model.SendSummary    = job.SendSummary;
                    model.Created        = job.Created;
                    model.Status         = job.Status;
                }

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

                // Create the breadcrumb
                var breadcrumb = new List <BreadcrumbItemViewModel>();
                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = "Jobs",
                    Link = "/Jobs"
                });

                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = job.Name,
                    Link = "/Jobs/" + job.JobId + "/Details"
                });

                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = "Edit"
                });

                ViewBag.Breadcrumb = breadcrumb;
            }

            catch (Exception ex)
            {
                LogService.Info("Jobs not found", ex.Message, ex.InnerException);
            }

            if (User.IsInRole("SystemAdministrator") || job.Collection.TenantId == CurrentTenant.TenantId)
            {
                return(View(model));
            }

            return(View("Authorize"));
        }
コード例 #17
0
        // GET: AdminController/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}

        // POST: AdminController/Create
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create(IFormCollection collection)
        //{
        //    try
        //    {
        //        return RedirectToAction(nameof(Index));
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        // GET: AdminController/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            var locationsFromDTO            = this.locationsService.GetAllLocations();
            List <SelectListItem> locations = new List <SelectListItem>();

            foreach (var location in locationsFromDTO)
            {
                SelectListItem l = new SelectListItem()
                {
                    Value = location.Id.ToString(),
                    Text  = location.Name
                };
                locations.Add(l);
            }

            var employmentTypesFromDTO            = this.jobsService.GetEmploymentTypes();
            List <SelectListItem> employmentTypes = new List <SelectListItem>();

            foreach (var et in employmentTypesFromDTO)
            {
                SelectListItem e = new SelectListItem()
                {
                    Value = et.Id.ToString(),
                    Text  = et.Name
                };
                employmentTypes.Add(e);
            }

            var seniorityLevelsFromDTO            = this.jobsService.GetSeniorityLevels();
            List <SelectListItem> seniorityLevels = new List <SelectListItem>();

            foreach (var sl in seniorityLevelsFromDTO)
            {
                SelectListItem s = new SelectListItem()
                {
                    Value = sl.Id.ToString(),
                    Text  = sl.Name
                };
                seniorityLevels.Add(s);
            }

            var industriesFromDTO = this.industriesService.GetAllIndustries();
            List <IndustryViewModel> industries = new List <IndustryViewModel>();

            foreach (var industry in industriesFromDTO)
            {
                IndustryViewModel i = new IndustryViewModel();
                i.Id   = industry.Id;
                i.Name = industry.Name;

                foreach (var j in industry.Jobs)
                {
                    i.Jobs.Add(new EditJobViewModel
                    {
                        Id             = j.Id,
                        Position       = j.Position,
                        Location       = j.Location.Name,
                        Description    = j.Description,
                        Salary         = j.Salary,
                        SubIndustry    = j.SubIndustry.Name,
                        EmploymentType = j.EmploymentType.Name,
                        SeniorityLevel = j.SeniorityLevel.Name
                    });
                }

                foreach (var subIndustry in industry.SubIndustries)
                {
                    i.SubIndustries.Add(new SubIndustryViewModel
                    {
                        Id   = subIndustry.Id,
                        Name = subIndustry.Name
                    });
                }

                industries.Add(i);
            }

            var job = this.jobsService.GetJobInfo((Guid)id, null);

            if (job == null)
            {
                return(this.NotFound());
            }
            var jobViewModel = new EditJobViewModel
            {
                Id             = job.Id,
                Position       = job.Position,
                Employer       = job.Employer,
                Location       = job.Location,
                Description    = job.Description,
                Salary         = job.Salary,
                Keywords       = String.Join(',', job.Keywords),
                SubIndustry    = job.SubIndustry,
                EmploymentType = job.EmploymentType,
                SeniorityLevel = job.SeniorityLevel
            };

            var viewModel = new JobFullInfoViewModel
            {
                Job             = jobViewModel,
                Industries      = industries,
                Locations       = locations,
                EmploymentTypes = employmentTypes,
                SeniorityLevels = seniorityLevels
            };

            return(this.View(viewModel));
        }