public ActionResult Create() { ProductFeatureDetailModels model = new ProductFeatureDetailModels(); model.IsActive = true; return(View(model)); }
// Get Detail public ProductFeatureDetailModels GetDetail(string ID) { ProductFeatureDetailModels ProductFeatureDetail = new ProductFeatureDetailModels(); try { ProductFeatureRequestModels paraBody = new ProductFeatureRequestModels(); paraBody.ID = ID; NSLog.Logger.Info("ListofProductFeatures Get Detail Request", paraBody); var result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.ProductFeatureAPIGetDetail, null, paraBody); NSLog.Logger.Info("ListofProductFeatures Get Detail Request", result); dynamic data = result.Data; var lstDataRaw = data["ProductFeatureDetail"]; var lstContent = JsonConvert.SerializeObject(lstDataRaw); ProductFeatureDetail = JsonConvert.DeserializeObject <ProductFeatureDetailModels>(lstContent); NSLog.Logger.Info("ListofProductFeatureGetDetailData", ProductFeatureDetail); if (result.Success) { } NSLog.Logger.Info("ListofProductFeatureGetDetailData", ProductFeatureDetail); return(ProductFeatureDetail); } catch (Exception ex) { NSLog.Logger.Error("ListofProductFeatureGetDetailData_Fail", ex); return(null); } }
public ActionResult Delete(ProductFeatureDetailModels model) { try { string msg = ""; var result = _factory.Delete(model.ID, CurrentUser.UserId, ref msg); if (!result) { ModelState.AddModelError("Name", Commons.ErrorMsg); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Delete", model)); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); } catch (Exception ex) { NSLog.Logger.Error("ListofProductFeatures_Delete: ", ex); ModelState.AddModelError("Name", Commons.ErrorMsg); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Delete", model)); } }
// Create Catagory public bool InsertOrUpdateCategory(ProductFeatureDetailModels model, string userid, ref string msg) { try { ProductFeatureRequestModels paraBody = new ProductFeatureRequestModels(); paraBody.CreatedUser = userid; paraBody.ID = model.ID; paraBody.ProductFeatureDetail = model; NSLog.Logger.Info("ListofProductFeatures Update Request", paraBody); //==================== var result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.ProductFeatureAPICreateOrEdit, null, paraBody); NSLog.Logger.Info("ListofProductFeatures Update Request", result); if (result != null) { if (result.Success) { return(true); } else { msg = result.Message; NSLog.Logger.Info("ListofProductFeaturesCreateorEdit", result.Message); return(false); } } else { NSLog.Logger.Info("ListofProductFeaturesCreateorEdit", result); return(false); } } catch (Exception e) { NSLog.Logger.Error("ListofProductFeaturesInsertOrUpdate_Fail", e); return(false); } }
public ActionResult Create(ProductFeatureDetailModels model) { try { if (model.Name == null) { ModelState.AddModelError("Name", "Name is Required"); } byte[] ImageURLphotoByte = null; byte[] IconURLphotoByte = null; if (model.ImageURLUpload != null && model.ImageURLUpload.ContentLength > 0) { Byte[] imgByte = new Byte[model.ImageURLUpload.ContentLength]; model.ImageURLUpload.InputStream.Read(imgByte, 0, model.ImageURLUpload.ContentLength); model.ImageURLPictureByte = imgByte; model.ImageURL = Guid.NewGuid() + Path.GetExtension(model.ImageURLUpload.FileName); model.ImageURLUpload = null; ImageURLphotoByte = imgByte; } if (model.IconURLUpload != null && model.IconURLUpload.ContentLength > 0) { Byte[] imgBytes = new Byte[model.IconURLUpload.ContentLength]; model.IconURLUpload.InputStream.Read(imgBytes, 0, model.IconURLUpload.ContentLength); model.IconURLPictureByte = imgBytes; model.IconURL = Guid.NewGuid() + Path.GetExtension(model.IconURLUpload.FileName); model.IconURLUpload = null; IconURLphotoByte = imgBytes; } if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(View(model)); } string msg = ""; bool result = _factory.InsertOrUpdateCategory(model, CurrentUser.UserId, ref msg); if (result) { //Save Image on Server if (!string.IsNullOrEmpty(model.ImageURL) && model.ImageURLPictureByte != null) { var originalDirectory = new DirectoryInfo(string.Format("{0}Uploads\\", Server.MapPath(@"\"))); var path = string.Format("{0}{1}", originalDirectory, model.ImageURL); MemoryStream ms = new MemoryStream(ImageURLphotoByte, 0, ImageURLphotoByte.Length); ms.Write(ImageURLphotoByte, 0, ImageURLphotoByte.Length); System.Drawing.Image imageTmp = System.Drawing.Image.FromStream(ms, true); ImageHelper.Me.SaveCroppedImage(imageTmp, path, model.ImageURL, ref ImageURLphotoByte); model.ImageURLPictureByte = ImageURLphotoByte; FTP.Upload(model.ImageURL, model.ImageURLPictureByte); ImageHelper.Me.TryDeleteImageUpdated(path); } //Save Image on Server if (!string.IsNullOrEmpty(model.IconURL) && model.IconURL != null) { var originalDirectory = new DirectoryInfo(string.Format("{0}Uploads\\", Server.MapPath(@"\"))); var path = string.Format("{0}{1}", originalDirectory, model.IconURL); MemoryStream ms = new MemoryStream(IconURLphotoByte, 0, IconURLphotoByte.Length); ms.Write(IconURLphotoByte, 0, IconURLphotoByte.Length); System.Drawing.Image imageTmp = System.Drawing.Image.FromStream(ms, true); ImageHelper.Me.SaveCroppedImage(imageTmp, path, model.IconURL, ref IconURLphotoByte); model.IconURLPictureByte = IconURLphotoByte; FTP.Upload(model.IconURL, model.IconURLPictureByte); ImageHelper.Me.TryDeleteImageUpdated(path); } return(RedirectToAction("Index")); } else { ModelState.AddModelError("Name", Commons.ErrorMsg /*msg*/); return(View(model)); } } catch (Exception ex) { NSLog.Logger.Error("ListofProductFeatures_Create : ", ex); return(new HttpStatusCodeResult(400, ex.Message)); } }
public PartialViewResult Edit(string id) { ProductFeatureDetailModels model = _factory.GetDetail(id); return(PartialView("_Edit", model)); }