Пример #1
0
        internal List <LotImages> getImagesByLotId(int lotId)
        {
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("sp_GetLotImagesByLotId", sqlConnection))
                {
                    try
                    {
                        sqlConnection.Open();
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@LotId", lotId);

                        SqlDataReader    rdr     = command.ExecuteReader();
                        List <LotImages> lotList = new List <LotImages>();
                        while (rdr.Read())
                        {
                            LotImages lot = new LotImages();
                            lot.Id          = Convert.ToInt32(rdr["Id"]);
                            lot.Imagesource = rdr["Imagesource"].ToString();
                            lot.LotId       = Convert.ToInt32(rdr["LotId"]);
                            lotList.Add(lot);
                        }
                        return(lotList);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
Пример #2
0
 public ActionResult GalleryUpload(int id)
 {
     try
     {
         HttpPostedFile file = null;
         if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
         {
             file = System.Web.HttpContext.Current.Request.Files["HttpPostedFileBase"];
         }
         string stamp    = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now);
         string filename = file.FileName.Split('.')[0] + stamp + "." + file.FileName.Split('.')[1];
         string pic      = System.IO.Path.GetFileName(filename);
         string path     = System.IO.Path.Combine(
             Server.MapPath("~/images/lots"), pic);
         // file is uploaded
         file.SaveAs(path);
         LotImages images = new LotImages();
         images.Imagesource = "/images/lots/" + pic;
         images.LotId       = id;
         images.Id          = images.Save();
         // after successfully uploading redirect the user
         return(PartialView("ImagePartial", images));
     }
     catch (Exception ex)
     {
         return(Json("ՁՍԽՈՂՈՒՄ:Աշխատանքը վերբեռնված չէ"));
     }
 }
Пример #3
0
 public JsonResult DeleteLotImage(int id)
 {
     try
     {
         LotImages.Delete(id);
         return(Json("Նկարը հաջողությամբ ջբջված է", JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json("Ձախողում! չի հաջողվել ջնջել:", JsonRequestBehavior.AllowGet));
     }
 }
Пример #4
0
        internal int saveLotImages(LotImages lotImages)
        {
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("sp_SaveLotImage", sqlConnection))
                {
                    try
                    {
                        sqlConnection.Open();
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@Imagesource", lotImages.Imagesource);
                        command.Parameters.AddWithValue("@LotId", lotImages.LotId);
                        return(Convert.ToInt32(command.ExecuteScalar()));
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }