示例#1
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListUndeletedAsync();

            if (!listOperation.Success)
            {
                return(OperationErrorBackToIndex(listOperation.Exception));
            }

            var finalList = new List <JobVM>();

            foreach (var item in listOperation.Result)
            {
                finalList.Add(JobVM.Parse(item));
            }

            var serviceList = await GetServiceViewModels(listOperation.Result.Select(x => x.ServiceId).Distinct().ToList());

            var clientList = await GetClientViewModels(listOperation.Result.Select(x => x.ClientId).Distinct().ToList());

            ViewData["Title"]       = "Jobs";
            ViewData["Services"]    = serviceList;
            ViewData["Clients"]     = clientList;
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            return(View(finalList));
        }
示例#2
0
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }

            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = JobVM.Parse(getOperation.Result);

            var listClientOperation = await _clientBO.ListUndeletedAsync();

            if (!listClientOperation.Success)
            {
                return(OperationErrorBackToIndex(listClientOperation.Exception));
            }

            var clientList = new List <SelectListItem>();

            foreach (var item in listClientOperation.Result)
            {
                var clientName = await _clientBO.ReadAsync(item.Id);

                var listItem = new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = (clientName.Result.FullName + " -- " + clientName.Result.Country)
                };

                if (item.Id == vm.ClientId)
                {
                    listItem.Selected = true;
                }

                clientList.Add(listItem);
            }

            ViewBag.Clients = clientList;

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Edit", Controller = "Jobs", Icon = "fa-edit", Text = "Edit"
            });

            ViewData["Title"]       = "Edit job";
            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
示例#3
0
        private Weekdays ConvertJobWeekdaysToEnum(JobVM jobVM)
        {
            Weekdays weekdays = 0;

            if (jobVM.Sunday)
            {
                weekdays |= Weekdays.Sunday;
            }
            if (jobVM.Monday)
            {
                weekdays |= Weekdays.Monday;
            }
            if (jobVM.Tuesday)
            {
                weekdays |= Weekdays.Tuesday;
            }
            if (jobVM.Wednesday)
            {
                weekdays |= Weekdays.Wednesday;
            }
            if (jobVM.Thursday)
            {
                weekdays |= Weekdays.Thursday;
            }
            if (jobVM.Friday)
            {
                weekdays |= Weekdays.Friday;
            }
            if (jobVM.Saturday)
            {
                weekdays |= Weekdays.Saturday;
            }
            return(weekdays);
        }
示例#4
0
        public async Task <IActionResult> Edit(Guid id, JobVM vm)
        {
            if (ModelState.IsValid)
            {
                var getOperation = await _bo.ReadAsync(id);

                if (!getOperation.Success)
                {
                    return(OperationErrorBackToIndex(getOperation.Exception));
                }

                if (getOperation.Result == null)
                {
                    return(RecordNotFound());
                }

                var result = getOperation.Result;

                if (!vm.CompareToModel(result))
                {
                    result = vm.ToJob(result);

                    var updateOperation = await _bo.UpdateAsync(result);

                    if (!updateOperation.Success)
                    {
                        TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception);
                        return(View(vm));
                    }

                    return(OperationSuccess("The record was successfully updated."));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
示例#5
0
        void StartNextJob()
        {
            CleanVideoEditor();
            JobVM nextJob = ViewModel.PendingJobs.FirstOrDefault();

            if (nextJob == null)
            {
                ViewModel.CurrentJob.Model = null;
                return;
            }
            ViewModel.CurrentJob.Model    = nextJob.Model;
            ViewModel.CurrentJob.Progress = (float)EditorState.START;
            ViewModel.CurrentJob.State    = JobState.Running;

            try {
                if (ViewModel.CurrentJob.Model is EditionJob)
                {
                    LoadEditionJob(ViewModel.CurrentJob.Model as EditionJob);
                }
                else
                {
                    LoadConversionJob(ViewModel.CurrentJob.Model as ConversionJob);
                }
            } catch (Exception ex) {
                ViewModel.CurrentJob.State = JobState.Error;
                Log.Exception(ex, true);
                Log.Error("Error rendering job: ", ViewModel.CurrentJob.Name);
                App.Current.Dialogs.ErrorMessage(Catalog.GetString("Error rendering job: ") + ex.Message);
                StartNextJob();
            }
        }
示例#6
0
 public ActionResult Create(JobVM model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (Db db = new Db())
     {
         JobDTO dto = new JobDTO();
         if (db.Jobs.Any(x => x.ClientName == model.ClientName) || db.Jobs.Any(x => x.DeployDate == model.DeployDate))
         {
             ModelState.AddModelError("", "Same client aready added");
         }
         dto.ClientName   = model.ClientName;
         dto.Address      = model.Address;
         dto.DeployDate   = model.DeployDate;
         dto.Description  = model.Description;
         dto.SoftwareName = model.SoftwareName;
         dto.Other        = model.Other;
         db.Jobs.Add(dto);
         db.SaveChanges();
     }
     TempData["SM"] = "It has been Added";
     return(RedirectToAction("Create"));
 }
示例#7
0
        public async Task <IActionResult> Update([FromBody] JobVM vm)
        {
            var getResult = await _bo.ReadAsync(vm.Id);

            if (!getResult.Success)
            {
                return(InternalServerError(getResult.Exception));
            }

            var item = getResult.Result;

            if (item == null)
            {
                return(NotFound());
            }

            if (vm.CompareToModel(item))
            {
                return(NotModified());
            }

            item = vm.ToJob(item);

            var updateResult = await _bo.UpdateAsync(item);

            if (!updateResult.Success)
            {
                return(InternalServerError(updateResult.Exception));
            }

            return(Ok());
        }
示例#8
0
        public async Task <IActionResult> Upsert(int?id)
        {
            IEnumerable <JobSearch> jsList = await _jsRepo.GetAllAsync(SD.JobSearchAPIPath);

            JobVM objVM = new JobVM()
            {
                JobSearchList = jsList.Select(i => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text  = i.Name,
                    Value = i.Id.ToString()
                })
            };

            if (id == null)
            {
                //true for insert or create
                return(View(objVM));
            }
            objVM.Job = await _jobsRepo.GetAsync(SD.JobsAPIPath, id.GetValueOrDefault());

            if (objVM.Job == null)
            {
                //update
                return(NotFound());
            }
            return(View(objVM));
        }
        public IActionResult PutJob(int id, JobVM jobVM)
        {
            if (ModelState.IsValid)
            {
                if (id != jobVM.Id)
                {
                    return(BadRequest());
                }

                try
                {
                    _jobRepo.UpdateJob(jobVM);
                    return(Ok());
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_jobRepo.JobExists(id))
                    {
                        return(NotFound());
                    }
                }
                catch (KeyNotFoundException)
                {
                    return(NotFound());
                }
                catch (Exception e)
                {
                    return(StatusCode(500, new { status = 500, message = e.Message }));
                }

                return(NoContent());
            }
            return(BadRequest());
        }
示例#10
0
        public IActionResult Index(int?page)
        {
            //ViewBag.Time = DateTime.Now.Minute;
            ViewBag.PageCount = Math.Ceiling((decimal)_context.Jobs.Count() / 4);
            ViewBag.Page      = page;
            JobVM jobVM = new JobVM();

            if (page == null)
            {
                jobVM.Categories = _context.Categories.ToList();
                jobVM.Jobs       = _context.Jobs.Where(x => x.isActivated).OrderByDescending(p => p.Id).Take(4)
                                   .Include(c => c.Category)
                                   .Include(c => c.Country)
                                   .Include(c => c.City)
                                   .Include(x => x.AppUser)
                                   .ToList();
                return(View(jobVM));
            }
            else
            {
                jobVM.Categories = _context.Categories.ToList();
                jobVM.Jobs       = _context.Jobs.Where(x => x.isActivated).OrderByDescending(p => p.Id).Skip(((int)page - 1) * 4).Take(4)
                                   .Include(c => c.Category)
                                   .Include(c => c.Country)
                                   .Include(c => c.City)
                                   .Include(x => x.AppUser)
                                   .ToList();
                return(View(jobVM));
            }
        }
示例#11
0
        public void Execute(object parameter)
        {
            Model.SaveFile savefile      = new Model.SaveFile();
            JobVM          tempViewModel = savefile.Load();

            ViewModel.Job   = tempViewModel.Job;
            ViewModel.Rooms = tempViewModel.Rooms;
        }
示例#12
0
        void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            // FIXME: Remove when we start using ICommand's
            JobVM job = ViewModel.Selection.FirstOrDefault();

            cancelbutton.Visible = job != null && job.State == JobState.Running;
            retrybutton.Visible  = job != null && (job.State == JobState.Error || job.State == JobState.Cancelled);
        }
示例#13
0
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }

            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getServiceOperation = await _serviceBO.ReadAsync(getOperation.Result.ServiceId);

            if (!getServiceOperation.Success)
            {
                return(OperationErrorBackToIndex(getServiceOperation.Exception));
            }

            if (getServiceOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getClientOperation = await _clientBO.ReadAsync(getOperation.Result.ClientId);

            if (!getClientOperation.Success)
            {
                return(OperationErrorBackToIndex(getClientOperation.Exception));
            }

            if (getClientOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = JobVM.Parse(getOperation.Result);

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Details", Controller = "Jobs", Icon = "fa-info-circle", Text = "Details"
            });

            ViewData["Title"]       = "Job details";
            ViewData["BreadCrumbs"] = crumbs;
            ViewData["Service"]     = ServiceVM.Parse(getServiceOperation.Result);
            ViewData["Client"]      = ClientVM.Parse(getClientOperation.Result);
            return(View(vm));
        }
 public string Create(JobVM jobVM)
 {
     _jobVM = new JobVM
     {
         CustomerName  = jobVM.CustomerName,
         CustomerPhone = jobVM.CustomerPhone,
         ServiceType   = jobVM.ServiceType
     };
     ViewBag.Job = _jobVM;
     return("All is well");
 }
        private async Task <List <JobVM> > GetJobViewModels(List <Guid> ids)
        {
            var filterOperation = await _jobBO.FilterAsync(x => ids.Contains(x.Id));

            var jobList = new List <JobVM>();

            foreach (var item in filterOperation.Result)
            {
                jobList.Add(JobVM.Parse(item));
            }

            return(jobList);
        }
        public JobVM Search(string searchString)
        {
            JobVM jobVM = null;

            if (searchString == null)
            {
                return(jobVM);
            }

            jobVM = GetJobs().FirstOrDefault(x => x.CustomerPhone.Contains(searchString) || x.CustomerName.ToLower().Contains(searchString.ToLower()));;

            return(jobVM);
        }
示例#17
0
        public async Task <IActionResult> CreateAsync([FromBody] JobVM vm)
        {
            var newJob = vm.ToJob();

            var result = await _bo.CreateAsync(newJob);

            if (!result.Success)
            {
                return(InternalServerError(result.Exception));
            }

            return(Created(Request.Path.Value, null));
        }
示例#18
0
        public void TestModel()
        {
            var encSettings = new EncodingSettings {
                OutputFile = "test.mp4",
            };
            var model = new Job(encSettings)
            {
            };
            var viewModel = new JobVM {
                Model = model
            };

            Assert.AreSame(model, viewModel.Model);
        }
示例#19
0
        public ActionResult Edit(int id)
        {
            JobVM model;

            using (Db db = new Db())
            {
                JobDTO dto = db.Jobs.Find(id);
                if (dto == null)
                {
                    return(Content("The List doesnt exist"));
                }
                model = new JobVM(dto);
            }
            return(View(model));
        }
示例#20
0
        public async Task <ActionResult <JobVM> > UpdateJob([FromRoute] Guid id, [FromBody] JobVM jobVM)
        {
            // Validation
            if (!ModelState.IsValid || id != jobVM.Id)
            {
                return(BadRequest(ModelState));
            }

            // Mapping
            Job job = this.mapper.Map <JobVM, Job>(jobVM);

            job = await this.bll.UpdateJobAsync(job);

            // Mapping
            return(Ok(this.mapper.Map <Job, JobVM>(job)));
        }
示例#21
0
        public dynamic PutJob(JobVM j)
        {
            var job = db.Jobs.Find(j.Id);

            job.Job_A_Title   = j.TitleAr;
            job.Job_E_Title   = j.TitleEn;
            job.Department_ID = j.DepartmentId;
            job.User_ID       = j.UserId;
            job.Last_Update   = DateTime.Now;
            var result = db.SaveChanges() > 0 ? true : false;

            return(new
            {
                result = result
            });
        }
示例#22
0
        public async Task <IActionResult> New(JobVM vm)
        {
            if (ModelState.IsValid)
            {
                var model           = vm.ToJob();
                var createOperation = await _bo.CreateAsync(model);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }

                return(OperationSuccess("The record was successfully created."));
            }
            return(View(vm));
        }
 public ActionResult <JobVM> PostJob([FromBody] JobVM jobVM)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var userId = _userManager.GetUserId(User);
             var result = _jobRepo.AddJob(jobVM, userId);
             return(Ok(result));
         }
         catch (Exception e)
         {
             return(StatusCode(500, new { message = e.Message }));
         }
     }
     return(BadRequest());
 }
        public ActionResult Create([Bind(Exclude = "SkillList")] JobVM jobVM, List <int> SkillList)
        {
            if (ModelState.IsValid)
            {
                //SkillList_@i
                Job job = new Job()
                {
                    JobTitle          = jobVM.JobTitle,
                    CatID             = jobVM.CatID,
                    ClientId          = User.Identity.GetUserId(),
                    Desc              = jobVM.Desc,
                    Price             = jobVM.Price,
                    ExperienceLevelId = jobVM.ExperienceLevelId
                };

                db.Jobs.Add(job);
                db.SaveChanges();
                foreach (var item in SkillList)
                {
                    JobSkills JobSkill = new JobSkills();
                    JobSkill.JobId   = job.ID;
                    JobSkill.SkillId = item;
                    db.JobSkills.Add(JobSkill);
                    db.SaveChanges();
                }
                return(RedirectToAction("ClientJobs", "Client"));
            }
            var skills = db.Skills.ToList();
            List <SkillModel> skillModels = new List <SkillModel>();

            foreach (var item in skills)
            {
                //SkillModel skillModel = new SkillModel() { Text = item.SkillsName, IsChecked = true,SkillId=item.ID,Value=1 };
                SkillModel skillModel = new SkillModel()
                {
                    Text = item.SkillsName, IsChecked = false, SkillId = item.ID
                };
                skillModels.Add(skillModel);
            }


            jobVM.SkillList           = skillModels;
            ViewBag.CatID             = new SelectList(db.JobCategory, "ID", "Name", jobVM.CatID);
            ViewBag.ExperienceLevelId = new SelectList(db.JobExperienceLevel, "ID", "ExperienceLevel", jobVM.ExperienceLevelId);
            return(View(jobVM));
        }
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }

            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getJobOperation = await _jobBO.ReadAsync(getOperation.Result.JobId);

            if (!getJobOperation.Success)
            {
                return(OperationErrorBackToIndex(getJobOperation.Exception));
            }

            if (getJobOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ProposalVM.Parse(getOperation.Result);

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Details", Controller = "Proposals", Icon = "fa-info-circle", Text = "Details"
            });

            ViewData["Title"]       = "Proposal details";
            ViewData["BreadCrumbs"] = crumbs;
            ViewData["Job"]         = JobVM.Parse(getJobOperation.Result);
            return(View(vm));
        }
        public ActionResult Edit(int JobId)
        {
            var jobEntity = _jobManager.GetByJobId(JobId);
            var jobModel  = new JobVM
            {
                JobID           = jobEntity.JobID,
                CityId          = jobEntity.CityId,
                JobImage        = jobEntity.JobImage,
                CreatedBY       = jobEntity.CreatedBY,
                CreatedDateTime = jobEntity.CreatedDateTime,
                JobTitle        = jobEntity.JobTitle,
                UpdatedBY       = jobEntity.UpdatedBY,
                IsActive        = jobEntity.IsActive,
                UpdatedDateTime = jobEntity.UpdatedDateTime
            };

            return(View("Form", jobModel));
        }
示例#27
0
        public dynamic PostJob(JobVM j)
        {
            var job = db.Jobs.Add(new Job
            {
                Job_A_Title   = j.TitleAr,
                Job_E_Title   = j.TitleEn,
                Department_ID = j.DepartmentId,
                User_ID       = j.UserId,
                Last_Update   = DateTime.Now
            });
            var result = db.SaveChanges() > 0 ? true : false;

            return(new
            {
                result = result,
                jobId = job.Job_ID
            });
        }
示例#28
0
        public void TestProperties()
        {
            var encSettings = new EncodingSettings {
                OutputFile = "test.mp4",
            };
            var model = new Job(encSettings)
            {
                Progress = 0,
                State    = JobState.Running,
            };
            var viewModel = new JobVM {
                Model = model
            };

            Assert.AreEqual("test.mp4", viewModel.Name);
            Assert.AreEqual(0, viewModel.Progress);
            Assert.AreEqual(JobState.Running, viewModel.State);
        }
示例#29
0
 public async Task <IActionResult> Upsert(JobVM obj)
 {
     if (ModelState.IsValid)
     {
         if (obj.Job.Id == 0)
         {
             await _jobsRepo.CreateAsync(SD.JobsAPIPath, obj.Job);
         }
         else
         {
             await _jobsRepo.UpdateAsync(SD.JobsAPIPath + obj.Job.Id, obj.Job);
         }
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(View(obj));
     }
 }
        public ActionResult Add(JobVM model)
        {
            if (ModelState.IsValid)
            {
                var fileName = "";
                if (Request.Form.Files.Count > 0)
                {
                    var file        = Request.Form.Files[0];
                    var webRootPath = _hostingEnvironment.WebRootPath;
                    var newPath     = Path.Combine(webRootPath, "images");
                    if (!Directory.Exists(newPath))
                    {
                        Directory.CreateDirectory(newPath);
                    }

                    if (file.Length > 0)
                    {
                        fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
                        var fullPath = Path.Combine(newPath, fileName);
                        using (var stream = new FileStream(fullPath, FileMode.Create))
                        {
                            file.CopyTo(stream);
                        }
                    }
                }

                var job = new Job()
                {
                    CityId          = model.CityId,
                    JobImage        = fileName,
                    CreatedBY       = "1",
                    CreatedDateTime = DateTime.Now,
                    JobTitle        = model.JobTitle,
                    UpdatedBY       = "1",
                    IsActive        = model.IsActive,
                    UpdatedDateTime = DateTime.Now
                };

                _jobManager.Create(job);
                return(RedirectToAction("Index", "Job"));
            }
            return(View("Form", model));
        }