public JsonResult SaveGolferType(GolferViewModel golferViewModel) { HttpResponseMessage response = new APIHelper.APICallMethod().GetHttpResponseMessage("SaveGolferDetails", "AdminPanel", golferViewModel); if (response.IsSuccessStatusCode) { var data = response.Content.ReadAsStringAsync().Result; ViewModel.ResponseModel.ResponseViewModel <Dictionary <string, bool> > dbBookingDetails = JsonConvert.DeserializeObject <ViewModel.ResponseModel.ResponseViewModel <Dictionary <string, bool> > >(data); if (dbBookingDetails.IdentityResult.Status == true) { return(Json(new { code = 0, message = "Success" })); } else { if (dbBookingDetails.IdentityResult.Message == "Invalid access details, Please log-out.") { return(Json(new { code = -99, message = "Please Login Again" })); } else { return(Json(new { code = -1, message = dbBookingDetails.IdentityResult.Message })); } } } else { return(Json(new { code = -2, message = "failed" })); } }
/// <summary> /// Get Golfer Detail By Golfer Id /// </summary> /// <param name="golferId"></param> /// <returns></returns> public JsonResult GetUserDetailByGolferId(long golferId) { GolferViewModel golferViewModel = new GolferViewModel() { GolferId = golferId }; HttpResponseMessage response = new APIHelper.APICallMethod().GetHttpResponseMessage("GetGolferProfileByGolferId", "AdminPanel", golferViewModel); if (response.IsSuccessStatusCode) { var data = response.Content.ReadAsStringAsync().Result; ViewModel.ResponseModel.ResponseViewModel <ViewModel.GolferViewModel> dbBookingDetails = JsonConvert.DeserializeObject <ViewModel.ResponseModel.ResponseViewModel <ViewModel.GolferViewModel> >(data); if (dbBookingDetails.IdentityResult.Status == true) { string convertedData = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/SearchGolfer/_GolferDetails.cshtml", dbBookingDetails.Content); return(Json(new { code = 0, message = convertedData })); } else { return(Json(new { code = -1, message = dbBookingDetails.IdentityResult.Message })); } } else { return(Json(new { code = -2, message = "failed" })); } }
public async Task <ActionResult> Create(GolferViewModel model) { try { if (!ModelState.IsValid) { ModelState.AddModelError("", "Create Golfer: Model state is invalid"); return(View(model)); } var dateCreated = DateTime.Now; model.DateJoined = dateCreated; var golfer = _mapper.Map <Golfer>(model); var isSuccess = await _repo.Create(golfer); if (!isSuccess) { ModelState.AddModelError("", "Create Golfer: Unable to Create a new golfer"); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { ModelState.AddModelError("", "Create Golfer: Something went wrong in the golfer creation"); return(View(model)); } }
public async Task <ActionResult> Edit(GolferViewModel model) { try { // update logic here if (!ModelState.IsValid) { return(View(model)); } var golfer = _mapper.Map <Golfer>(model); var isSuccess = await _repo.Update(golfer); if (!isSuccess) { ModelState.AddModelError("", "Edit Golfer: Update not successfull"); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { ModelState.AddModelError("", "Edit Golfer: Something went wrong"); return(View(model)); } }
// GET: UpdateGolfer public ActionResult Index(long golferId) { GolferViewModel golferViewModel = new GolferViewModel() { GolferId = golferId }; HttpResponseMessage response = new APIHelper.APICallMethod().GetHttpResponseMessage("GetGolferProfileByGolferId", "AdminPanel", golferViewModel); if (response.IsSuccessStatusCode) { var data = response.Content.ReadAsStringAsync().Result; ViewModel.ResponseModel.ResponseViewModel <ViewModel.GolferViewModel> dbBookingDetails = JsonConvert.DeserializeObject <ViewModel.ResponseModel.ResponseViewModel <ViewModel.GolferViewModel> >(data); if (dbBookingDetails.IdentityResult.Status == true) { dbBookingDetails.Content.MemberTypeViewModels = GetAllMemberType(); dbBookingDetails.Content.GenderTypeViewModels = GetAllGenderType(); dbBookingDetails.Content.MaritalStatusViewModels = GetAllMaritalStatusType(); dbBookingDetails.Content.SalutationViewModels = GetAllSalutationType(); return(View(dbBookingDetails.Content)); } else { return(View()); } } else { return(View()); } }
public JsonResult UpdateGolferPasswordPopUp(long golferId) { GolferViewModel golferViewModel = new GolferViewModel() { GolferId = golferId, }; string convertedData = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/SearchGolfer/_ChangePassword.cshtml", golferViewModel); return(Json(new { code = 0, message = convertedData })); }
public JsonResult UpdatePopUp(long golferId, bool status) { GolferViewModel golferViewModel = new GolferViewModel() { GolferId = golferId, IsBlocked = status }; string convertedData = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/SearchGolfer/_UpdateGolferStatus.cshtml", golferViewModel); return(Json(new { code = 0, message = convertedData })); }
// GET: AddGolfer public ActionResult Index() { GolferViewModel golferViewModel = new GolferViewModel() { MemberTypeViewModels = GetAllMemberType(), GenderTypeViewModels = GetAllGenderType(), MaritalStatusViewModels = GetAllMaritalStatusType(), SalutationViewModels = GetAllSalutationType() }; return(View(golferViewModel)); }
public async Task <ActionResult> Delete(Guid id, GolferViewModel model) { try { var golfer = await _repo.FindByID(id); if (golfer == null) { return(NotFound()); } var isSuccess = await _repo.Delete(golfer); if (!isSuccess) { return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { return(View(model)); } }
public ActionResult ImportGolferExcel(GolferViewModel model) { try { string str1 = Guid.NewGuid().ToString(); HttpPostedFileBase file2 = model.Attachment; if (file2.ContentLength != 0) { string path = "~/Uploads/Images"; if (!Directory.Exists(this.Server.MapPath(path))) { Directory.CreateDirectory(this.Server.MapPath(path)); } string extension = Path.GetExtension(file2.FileName); string str2 = Path.Combine(this.Server.MapPath(path), Path.GetFileName(str1 + extension)); if (!str2.EndsWith(".xls") && !str2.EndsWith(".xlsx")) { return(this.Content("{\"name\":\"Please Choose A File Of Type .xls Or .xlsx\",\"code\":\"-1\" }", "application/json")); } file2.SaveAs(str2); HttpClient httpClient = new HttpClient(); int int32 = Convert.ToInt32(Constants.ApiAccess.HttpTime); httpClient.Timeout = TimeSpan.FromMinutes((double)int32); httpClient.BaseAddress = new Uri(Constants.Url.WebApiUrl); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); MultipartFormDataContent multipartFormDataContent = new MultipartFormDataContent(); KeyValuePair <string, string>[] keyValuePairArray = new KeyValuePair <string, string>[2] { new KeyValuePair <string, string>("Foo", "Bar"), new KeyValuePair <string, string>("More", "Less") }; foreach (KeyValuePair <string, string> keyValuePair in keyValuePairArray) { multipartFormDataContent.Add((HttpContent) new StringContent(keyValuePair.Value), keyValuePair.Key); } ByteArrayContent byteArrayContent = new ByteArrayContent(System.IO.File.ReadAllBytes(str2)); byteArrayContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "attachment", FileName = "Foo" + extension }; multipartFormDataContent.Add((HttpContent)byteArrayContent); HttpResponseMessage result = httpClient.PostAsync("api/ExeclUpload/UploadExcel", (HttpContent)multipartFormDataContent).Result; if (result.IsSuccessStatusCode) { var data = result.Content.ReadAsStringAsync().Result; var Response = JsonConvert.DeserializeObject <List <GolferViewModel> >(data); string convertedData = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/AddGolfer/_FailedRecord.cshtml", Response); return(Content(convertedData)); } List <GolferViewModel> golfer = new List <GolferViewModel>() { new GolferViewModel() { Message = "Failed" } }; string convertedData1 = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/AddGolfer/_FailedRecord.cshtml", Response); return(Content(convertedData1)); } List <GolferViewModel> golfer2 = new List <GolferViewModel>() { new GolferViewModel() { Message = "Failed" } }; string convertedData2 = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/AddGolfer/_FailedRecord.cshtml", Response); return(Content(convertedData2)); } catch (Exception ex) { List <GolferViewModel> golfer = new List <GolferViewModel>() { new GolferViewModel() { Message = "Failed" } }; string convertedData1 = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/AddGolfer/_FailedRecord.cshtml", Response); return(Content(convertedData1)); } }