Exemplo n.º 1
0
        public async Task <ActionResult> Upload(CareerFormModel careerForm, HttpPostedFileBase file)
        {
            string fileName    = "";
            var    fileDetails = new List <FileDetail>();

            if (file != null && file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                FileDetail fileDetail = new FileDetail()
                {
                    FileName  = fileName,
                    Extension = Path.GetExtension(fileName),
                    Id        = Guid.NewGuid()
                };
                fileDetails.Add(fileDetail);

                var path = Path.Combine(Server.MapPath("~/Uploads/"), fileDetail.Id + fileDetail.Extension);
                file.SaveAs(path);
                careerForm.File = fileDetails[0].Id.ToString() + fileDetails[0].Extension.ToString();
            }

            careerForm.CareerId = careerForm.CareerId;

            if (string.IsNullOrEmpty(careerForm.FullName))
            {
                ModelState.AddModelError("FirstName", "Last_Name_Required");
            }
            if (string.IsNullOrEmpty(careerForm.Email))
            {
                ModelState.AddModelError("Email", "Email_Required");
            }
            if (string.IsNullOrEmpty(careerForm.PhoneNo))
            {
                ModelState.AddModelError("PhoneNo", "PhoneNo_Required");
            }
            if (string.IsNullOrEmpty(careerForm.File))
            {
                ModelState.AddModelError("Attach", "Attach_file_Required");
            }
            var general = url + "CareerForms";

            if (ModelState.IsValid)
            {
                HttpResponseMessage responseMessageApi = await _client.PostAsJsonAsync(general, careerForm);

                if (responseMessageApi.IsSuccessStatusCode)
                {
                    var responseData = responseMessageApi.Content.ReadAsStringAsync().Result;
                    if (responseData != null)
                    {
                        TempData["alertMessage"] = "Thanks, Kindly our team will contact with you shortly";
                    }
                }
                return(RedirectToAction("Index"));
            }

            return(View(careerForm));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Details(int id)
        {
            var CareerModel     = new CareerModel();
            var careerForm      = new CareerFormModel();
            var general         = url + "Careers/GetCareerById?careerId=" + id;
            var responseMessage = await _client.GetAsync(general);

            if (!responseMessage.IsSuccessStatusCode)
            {
                return(View(CareerModel));
            }
            var responseData = responseMessage.Content.ReadAsStringAsync().Result;

            CareerModel         = JsonConvert.DeserializeObject <CareerModel>(responseData);
            careerForm.CareerId = CareerModel.CareerId;
            ViewBag.Title       = CareerModel.Title;
            return(RedirectToAction("Upload", careerForm));

            //return View(careerForm);
        }
Exemplo n.º 3
0
 // [HandleError]
 public ActionResult Upload(CareerFormModel careerForm)
 {
     return(View(careerForm));
 }
Exemplo n.º 4
0
        public IHttpActionResult EditCareerForm([FromBody] CareerFormModel careerFormModel)
        {
            var reurnCareerForm = _careerFormFacade.EditCareerForm(Mapper.Map <CareerFormDto>(careerFormModel), UserId, TenantId);

            return(Ok(reurnCareerForm));
        }