public ActionResult CreateDocument(String pConsumerID, String pOwnerID, String ppropertyID, String pSiteID, String pClientID, String pMeterID) { if (Session["Login"] != null) { try { if ((pClientID != null) && (!String.IsNullOrEmpty(pClientID)) && (pSiteID != null) && (!String.IsNullOrEmpty(pSiteID)) && (ppropertyID != null) && (!String.IsNullOrEmpty(ppropertyID)) && (pConsumerID != null) && (!String.IsNullOrEmpty(pConsumerID)) && (pMeterID != null) && (!String.IsNullOrEmpty(pMeterID)) && (pMeterID != null) && (!String.IsNullOrEmpty(pMeterID))) { CorrespondenceDocumentMaster corres = new CorrespondenceDocumentMaster(); corres.ClientID = pClientID; corres.SiteID = pSiteID; corres.PropertyID = ppropertyID; corres.MeterID = pMeterID; corres.OwnerID = pOwnerID; corres.ConsumerID = pConsumerID; ViewBag.FileTypeList = new SelectList(BAL.Common.DocumentTypeDropDownList(), "Value", "Text"); return PartialView("AddDocument", corres); } else { return Content(" Try Again"); } } catch (Exception ex) { return Content("Error:" + ex.StackTrace.ToString()); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult InsertDocument(CorrespondenceDocumentMaster model) { if (Session["Login"] != null) { LoginSession loginsession = (LoginSession)Session["Login"]; if (String.IsNullOrEmpty(model.DocumentName.ToString())) { ModelState.AddModelError("Document Name ", "Please Enter Document Name"); } if (String.IsNullOrEmpty(model.IssueDate.ToString())) { ModelState.AddModelError(" Issue Date ", "Please Select Date "); } if (String.IsNullOrEmpty(model.DocumentType.ToString())) { ModelState.AddModelError("Document Type ", "Please Select Type "); } try { String filePath = String.Empty; foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[inputTagName]; if (file.ContentLength > 0) { var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName); var path = Path.Combine(Server.MapPath("~/PdfContent/Document"), fileName); file.SaveAs(path); model.FileName = fileName.ToString().Trim(); } }//foreach if (String.IsNullOrEmpty(model.FileName.ToString())) { ModelState.AddModelError("Upload File ", "Please Upload File "); } if (ModelState.IsValid) { SearchConsumer Consumerobj = new SearchConsumer(); Consumerobj.ClientID = model.ClientID; Consumerobj.SiteID = model.SiteID; Consumerobj.PropertyID = model.PropertyID; Consumerobj.MeterID = model.MeterID; Consumerobj.OwnerID = model.OwnerID; Consumerobj.ConsumerID = model.ConsumerID; model.CreateBy = Convert.ToInt64(loginsession.UserID); if (BAL.CorrespondenceModel.CreateCorrespondenceDocument(model)) { TempData["SearchParamList"] = Consumerobj; return RedirectToAction("SearchCorresspondenceDetails", "Search"); // return Json(new { result = 1, message = "Record was successfully Saved!" }); } else { TempData["SearchParamList"] = Consumerobj; return RedirectToAction("SearchCorresspondenceDetails", "Search"); // return Json(new { result = 0, message = "Try again " }); } } else { String errorMessage = String.Empty; String exception = String.Empty; foreach (var modelStateVal in ViewData.ModelState.Values) { foreach (var error in modelStateVal.Errors) { errorMessage = error.ErrorMessage; exception = error.Exception.ToString(); } } return Content("ErrorMessage" + ":" + exception); } } catch (Exception ex) { return Content("ErrorMessage" + ":" + ex.Message); } } else { return RedirectToAction("Index", "Home"); } }
public static Boolean CreateCorrespondenceDocument(CorrespondenceDocumentMaster Correspondence) { Boolean flag = false; try { IRecordInsert objtext = new BALCorrespondenceDocument(); flag = objtext.AddRecord(Correspondence); } catch (Exception ex) { throw; } return flag; }