public RelatedItemsController(ICreateItems createItems, IUpdateItems updateItems, IGetRelatedItems getRelatedItems, IRelatedItemsService relatedItemsService, RelatedItemsEditModel relatedItemsEditModel) { this._createItems = createItems; this._updateItems = updateItems; this._getRelatedItems = getRelatedItems; this._RelatedItemsService = relatedItemsService; this.RelatedItemsEditModel = relatedItemsEditModel; }
public ActionResult Delete(RelatedItemsEditModel itemsEditModel) { sqlCommand = new SqlCommand(); try { string type = "Delete"; sqlCommand = this._updateItems.UpdateItemsData(itemsEditModel, type); } catch (Exception ex) { ViewBag.FileStatus = ex; } return(RedirectToAction("Index", "Home")); }
// GET: RelatedItems/Edit/5 public ActionResult Edit(int id) { this.RelatedItemsEditModel = this._RelatedItemsService.FillData(id); if (this.RelatedItemsEditModel.Description != null && this.RelatedItemsEditModel.Image != null && this.RelatedItemsEditModel.Name != null && this.RelatedItemsEditModel.Title != null) { return(View(this.RelatedItemsEditModel)); } else { return(PartialView("_404")); } }
public SqlCommand CreateHeaderData(RelatedItemsEditModel relatedItemsEditModel) { using (sqlConnection = new SqlConnection(SqlConn.ConnectionString)) { sqlConnection.Open(); sqlCommand = new SqlCommand("SpMasterRelatedItems", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@StatementType", "Insert"); sqlCommand.Parameters.AddWithValue("@RelatedTitle", relatedItemsEditModel.Title); sqlCommand.Parameters.AddWithValue("@RelatedName", relatedItemsEditModel.Name); sqlCommand.Parameters.AddWithValue("@RelatedDesc", relatedItemsEditModel.Description); sqlCommand.Parameters.AddWithValue("@RelatedImage", relatedItemsEditModel.Image); sqlCommand.ExecuteNonQuery(); } return(sqlCommand); }
public ActionResult Create(RelatedItemsEditModel relatedItemsEditModel, HttpPostedFileBase Image) { sqlCommand = new SqlCommand(); try { if (Image != null) { string filename = System.IO.Path.GetFileName(Image.FileName); string path = System.IO.Path.Combine(Server.MapPath("~/UploadedFiles"), filename); relatedItemsEditModel.Image = Image.FileName; Image.SaveAs(path); } ViewBag.FileStatus = "File uploaded successfully."; sqlCommand = this._createItems.CreateHeaderData(relatedItemsEditModel); } catch (Exception) { ViewBag.FileStatus = "Error while file uploading."; } return(RedirectToAction("Index", "Home")); }