public bool Save_CustomerImage(bool isOnlyDelete, CustomerImageInfo obj, string UserCode, out string errormsg) { return(wsCustomer.Save_CustomerImage(isOnlyDelete, obj, UserCode, out errormsg)); }
public ActionResult Save_CustomerImageList(string isOnlyDelete, string ImageId, string CustomerId, string IsMain, string IsActive, HttpPostedFileBase[] files) { string fileName = "", path = ""; using (Bill_Svc.BillServiceClient iGstSvc = new Bill_Svc.BillServiceClient()) { CustomerImageInfo objCustomerImage = null; if (files == null && isOnlyDelete.Trim().ToUpper() == "Y") { objCustomerImage = new CustomerImageInfo(); objCustomerImage.CustomerId = CustomerId.Trim().Length == 0 ? 0 : Convert.ToInt32(CustomerId); objCustomerImage.ImageId = ImageId.Trim().Length == 0 ? 0 : Convert.ToInt32(ImageId); objCustomerImage.IsActive = IsActive.Trim().ToUpper(); objCustomerImage.Ismain = IsMain.Trim().ToUpper(); objCustomerImage.IsActive = IsActive.Trim().ToUpper(); if (iGstSvc.Save_CustomerImage(isOnlyDelete.Trim().ToUpper() == "Y", objCustomerImage, ((UserInfo)Session["UserDetails"]).UserCode, out ErrorMessage)) { //If delete success then file should be deleted if (isOnlyDelete.Trim().ToUpper() == "Y") { try { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch (Exception ex) { ErrorMessage = ErrorMessage + ex.Message; } } return(Json("Ok", JsonRequestBehavior.AllowGet)); } } if (files != null) { foreach (HttpPostedFileBase file in files) { objCustomerImage = new CustomerImageInfo(); if (ImageId.Trim().Replace("0", "").Length == 0) { fileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(file.FileName); path = System.IO.Path.Combine(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["UploadDataPath"].ToString()), fileName); file.SaveAs(path); objCustomerImage.FileName = fileName; objCustomerImage.FileType = file.ContentType; } objCustomerImage.CustomerId = Convert.ToInt32(CustomerId); objCustomerImage.ImageId = ImageId.Trim().Length == 0 ? 0 : Convert.ToInt32(ImageId); objCustomerImage.IsActive = IsActive.Trim().ToUpper(); objCustomerImage.Ismain = IsMain.Trim().ToUpper(); objCustomerImage.IsActive = IsActive.Trim().ToUpper(); if (iGstSvc.Save_CustomerImage(isOnlyDelete.Trim().ToUpper() == "Y", objCustomerImage, ((UserInfo)Session["UserDetails"]).UserCode, out ErrorMessage)) { //If delete success then file should be deleted if (isOnlyDelete.Trim().ToUpper() == "Y") { try { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch (Exception ex) { ErrorMessage = ErrorMessage + ex.Message; } if (ErrorMessage.Trim().Length > 0 && ImageId.Trim().Replace("0", "").Length == 0) { try { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch (Exception ex) { ErrorMessage = ErrorMessage + ex.Message; } } return(Json(ErrorMessage, JsonRequestBehavior.AllowGet)); } } } return(Json("Ok", JsonRequestBehavior.AllowGet)); } } return(Json(ErrorMessage, JsonRequestBehavior.AllowGet)); }