Пример #1
0
 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;
 }
Пример #2
0
 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"));
 }
Пример #3
0
 // 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"));
     }
 }
Пример #4
0
 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);
 }
Пример #5
0
 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"));
 }