Exemplo n.º 1
0
        public async Task <IActionResult> Resources(string resourceType, int?page)
        {
            var             requestUrl = $"{BaseUrl}{apiUriResources}/GetResources?resourcetype={resourceType}";
            ResourcePageDTO resources  = new ResourcePageDTO();
            ResourceVM      resourceVM = new ResourceVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    resources = await response.Content.ReadAsAsync <ResourcePageDTO>();
                }
                else
                {
                    resourceVM.OutputHandler = await response.Content.ReadAsAsync <OutputHandler>();
                }
            };

            //resources.ResourceCategories = await StaticDataHandler.GetResourceCategory(BaseUrl);


            resourceVM.PageSetup.PageTitle = resourceType;
            resourceVM.ResourceCategories  = resources.ResourceCategories;
            resourceVM.PaginatedResources  = await PaginatedList <ResourceDTO> .CreateAsync(resources.Resources, page ?? 1, 6);

            resourceVM.Resources = resources.Resources;
            return(View(resourceVM));
        }
Exemplo n.º 2
0
        public IHttpActionResult CreateResource([FromBody] ResourceVM res)
        {
            var mng = new ResourceManager();

            mng.AddNewResource(ResourceMapper.MapResourceVM(res));

            return(Ok(res));
        }
Exemplo n.º 3
0
        // POST api/<controller>
        public IHttpActionResult Post(ResourceVM item)
        {
            BL.ResourceManager mng      = new BL.ResourceManager();
            Resource           resource = ResourceMapper.MapResourceVM(item);

            mng.AddNewResource(resource);
            return(Ok(item));
        }
Exemplo n.º 4
0
        public static Resource MapResourceVM(ResourceVM vm)
        {
            Resource res = new Resource
            {
                ResourceId = vm.ResourceId,
                Username   = vm.Username,
                FirstName  = vm.FirstName,
                LastName   = vm.LastName
            };

            return(res);
        }
Exemplo n.º 5
0
        public static ResourceVM MapResource(Resource entity)
        {
            ResourceVM res = new ResourceVM
            {
                ResourceId = entity.ResourceId,
                Username   = entity.Username,
                FirstName  = entity.FirstName,
                LastName   = entity.LastName
            };

            return(res);
        }
Exemplo n.º 6
0
        public IHttpActionResult GetResource(int id)
        {
            BL.ResourceManager mng      = new BL.ResourceManager();
            Resource           resource = mng.GetResourceById(id);

            if (resource == null)
            {
                return(NotFound());
            }
            ResourceVM res = ResourceMapper.MapResource(resource);

            return(Ok(res));
        }
Exemplo n.º 7
0
        public static Resource MapResourceVM(ResourceVM vm)
        {
            var res = new Resource
            {
                ResourceId   = vm.ResourceId,
                Username     = vm.Username,
                FirstName    = vm.FirstName,
                LastName     = vm.LastName,
                IsActive     = vm.IsActive,
                EmailAddress = vm.EmailAddress
            };

            return(res);
        }
Exemplo n.º 8
0
        public static ResourceVM MapResource(Resource entity)
        {
            var res = new ResourceVM
            {
                ResourceId   = entity.ResourceId,
                Username     = entity.Username,
                FirstName    = entity.FirstName,
                LastName     = entity.LastName,
                IsActive     = entity.IsActive,
                EmailAddress = entity.EmailAddress
            };

            return(res);
        }
Exemplo n.º 9
0
        public async Task <IActionResult> ResourcesForAdmin(bool isDeleteFailed, string error)
        {
            var user = await StaticDataHandler.GetSessionDetails();

            var        requestUrl = $"{BaseUrl}{apiUriResources}/GetResourcesForAdmin";
            ResourceVM resources  = new ResourceVM(_configuration);

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.Token);
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                OutputHandler outputHandler = new OutputHandler();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    if (isDeleteFailed) //This is coming from delete function if anything wrong happens there, throw error
                    {
                        outputHandler.IsErrorOccured = true;
                        if (string.IsNullOrEmpty(error))
                        {
                            outputHandler.Message = "Something went wrong, Delete failed. Check if related records exist e.g events or Media";
                        }
                        else
                        {
                            outputHandler.Message = error;
                        }
                    }
                    else
                    {
                        outputHandler.IsErrorOccured = false;
                    }

                    resources.OutputHandler = outputHandler; //tired
                    resources.Resources     = await response.Content.ReadAsAsync <IEnumerable <ResourceDTO> >();
                }
                else if (response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    resources.OutputHandler.IsErrorOccured = true;
                    resources.OutputHandler.Message        = "You're not Authorized to perfom this task";
                }
                else
                {
                    outputHandler.IsErrorOccured = false;
                };
            };
            return(View(resources));
        }
Exemplo n.º 10
0
        public ActionResult Create(ResourceVM r, HttpPostedFileBase File)
        {
            String picture;

            //ce if va vérifier si le modéle est valide et que le file n'est pas vide(ou null)
            if (!ModelState.IsValid || File == null || File.ContentLength == 0)
            {
                System.Diagnostics.Debug.WriteLine("ABORT ABORT  !!!!!! MISSION IMPOSSIBLE !!!!!!!");
                picture = "Default.jpeg";
            }
            else
            {
                picture = File.FileName;
            }
            ResourceVM resource = new ResourceVM();

            us.Add(new user
            {
                name         = r.name,
                emailAddress = r.emailaddress,
                userType     = "Resource"
            });
            us.Commit();
            rs.Add(new ressource
            {
                availability = "Available",
                contractType = "InterMandate",
                isActive     = true,
                isOnLeave    = false,
                note         = r.note,
                rate         = r.rate,
                photo        = picture,
                userId       = rs.getUserId(r.name, r.emailaddress),
                sector       = r.sector,
                seniority    = r.seniority
            });
            rs.Commit();
            if (File.ContentLength > 0)
            {
                var path = Path.Combine(Server.MapPath("~/Content/Upload/Pictures/"), File.FileName);
                File.SaveAs(path);
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> ResourceDetails(int resourceId)
        {
            var        requestUrl = $"{BaseUrl}{apiUriResources}/GetResourceDetails?resourceId={resourceId}";
            ResourceVM resource   = new ResourceVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    resource.Resource = await response.Content.ReadAsAsync <ResourceDTO>();
                }
                ;
                resource.ResourceCategories = await StaticDataHandler.GetResourceCategory(BaseUrl);
            };
            return(View(resource));
        }
Exemplo n.º 12
0
        // GET: Resource/Details/5
        public ActionResult Details(int id)
        {
            var        r   = rs.GetById(id);
            ResourceVM res = new ResourceVM
            {
                availability = r.availability,
                contractType = r.contractType,
                isActive     = r.isActive ?? true,
                isOnLeave    = r.isOnLeave ?? false,
                note         = r.note,
                rate         = r.rate,
                photo        = r.photo,
                userId       = id,
                sector       = r.sector,
                seniority    = r.seniority,
                leaveId      = r.leaveId ?? 0,
                projectId    = r.projectId ?? 0,
                mandateId    = r.mandateId ?? 0,
                name         = rs.getNameFromId(r.userId),
                resumeId     = r.resumeId ?? 0
            };

            res.name = rs.getNameFromId(res.userId);
            if (res.leaveId != 0)
            {
                res.leave = rs.getLeave(res.leaveId);
            }
            if (res.resumeId != 0)
            {
                res.resume = rs.getResume(res.resumeId);
            }
            if (res.mandateId != 0)
            {
                res.mandate = rs.getMandate(res.mandateId);
            }
            if (res.projectId != 0)
            {
                res.project = rs.getProject(res.projectId);
            }
            ViewBag.result = res;
            return(View());
        }
Exemplo n.º 13
0
        public async Task <IActionResult> ResourcesByCategory(string name, int id)
        {
            var        requestUrl = $"{BaseUrl}{apiUriResources}/ResourcesByCategory?categoryId={id}";
            ResourceVM resources  = new ResourceVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    resources.Resources = await response.Content.ReadAsAsync <IEnumerable <ResourceDTO> >();
                }
                ;
            };
            resources.ResourceCategories = await StaticDataHandler.GetResourceCategory(BaseUrl);

            resources.PageHeader = name; //This is the category name carried over from the resource details page
            return(View(resources));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> PastorAubrey()
        {
            PageDTO         pastorAubreyPage = new PageDTO(_configuration);
            var             requestUrl       = $"{BaseUrl}{apiUriResources}/GetFeaturedResources";
            ResourcePageDTO resources        = new ResourcePageDTO();
            ResourceVM      resourceVM       = new ResourceVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    pastorAubreyPage.Resources = await response.Content.ReadAsAsync <IEnumerable <ResourceDTO> >();
                }
                else
                {
                    resourceVM.OutputHandler = await response.Content.ReadAsAsync <OutputHandler>();
                }
            };

            return(View(pastorAubreyPage));
        }