public async Task <IActionResult> New()
        {
            var listServiceOperation = await _serviceBO.ListUndeletedAsync();

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

            var serviceList = new List <SelectListItem>();

            foreach (var item in listServiceOperation.Result)
            {
                serviceList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                });
            }

            ViewBag.Services = serviceList;

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "ServicesProvided", Icon = "fa-plus-circle", Text = "New"
            });

            ViewData["Title"]       = "New service provided";
            ViewData["BreadCrumbs"] = crumbs;
            return(View());
        }
        public async Task <IActionResult> New()
        {
            var listServiceOperation = await _serviceBO.ListUndeletedAsync();

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

            var serviceList = new List <SelectListItem>();

            foreach (var item in listServiceOperation.Result)
            {
                serviceList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                });
            }

            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 _profileBO.ReadAsync(item.ProfileId);

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

            ViewBag.Services = serviceList;
            ViewBag.Clients  = clientList;

            var crumbs = GetCrumbs();

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

            ViewData["Title"]       = "New job";
            ViewData["BreadCrumbs"] = crumbs;
            return(View());
        }
Exemple #3
0
        public void TestDeleteServiceAsync()
        {
            ApplicationSeeder.Seed();

            var bo = new ServiceBO();

            var resList = bo.ListAsync().Result;
            var total   = resList.Result.Count;

            var resDelete = bo.Delete(resList.Result.First().Id);

            var list = bo.ListUndeletedAsync().Result;

            Assert.IsTrue(resDelete.Success && resList.Success && list.Result.Count == (total - 1));
        }
Exemple #4
0
        public void TestUpdateServiceAsync()
        {
            ApplicationSeeder.Seed();

            var bo = new ServiceBO();

            var resList = bo.ListAsync().Result;

            var item = resList.Result.FirstOrDefault();

            item.IsActive = false;

            var resUpdate = bo.UpdateAsync(item).Result;

            var list = bo.ListUndeletedAsync().Result;

            Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().IsActive == false);
        }
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListUndeletedAsync();

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

            var finalList = new List <ServiceVM>();

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

            ViewData["Title"]       = "Services";
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            return(View(finalList));
        }