示例#1
0
        [Route("Edit"), HttpPost]//פונקציה שעורכת פרטי מוצר
        public IHttpActionResult Edit()
        {
            var httpRequest = HttpContext.Current.Request;
            // System.Diagnostics.Debug.WriteLine(httpRequest.Params["product"]);
            var product    = new JavaScriptSerializer().DeserializeObject(httpRequest.Params["product"]);
            var dictionary = (Dictionary <string, object>)product;

            DTO.ProductToGMH p = new DTO.ProductToGMH {
            };
            p.ProductCodeToGMH      = (int)dictionary["ProductCodeToGMH"];
            p.ProductCode           = (int)dictionary["ProductCode"];
            p.FreeDescription       = (string)dictionary["FreeDescription"];
            p.IsDisposable          = (bool)dictionary["IsDisposable"];
            p.SecurityDepositAmount = (int?)dictionary["SecurityDepositAmount"];
            p.Status = (string)dictionary["Status"];
            string imageName;
            //Upload Image
            int           c      = httpRequest.Files.Count;
            List <string> photos = new List <string>();

            for (int i = 0; i < c; i++)
            {
                var postedFile = httpRequest.Files["Image" + i];
                //Create custom filename
                if (postedFile != null)
                {
                    imageName = postedFile.FileName;
                    // imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
                    var filePath = HttpContext.Current.Server.MapPath("~/image/" + imageName);
                    postedFile.SaveAs(filePath);
                    photos.Add(postedFile.FileName);
                }
            }
            return(Ok(BL.productsBL.edit(p, photos)));
        }
 public static DAL.PRODUCTtoGMH convertToDal(DTO.ProductToGMH p)
 {
     return(new DAL.PRODUCTtoGMH
     {
         Amount = p.Amount,
         FreeDescription = p.FreeDescription,
         GmhCode = p.GmhCode,
         IsDisposable = p.IsDisposable,
         ProductCode = p.ProductCode,
         ProductCodeToGMH = p.ProductCodeToGMH,
         SecurityDepositAmount = p.SecurityDepositAmount,
         Status = p.Status
     });
 }
示例#3
0
 [Route("GetLendings"), HttpPost]//פונקציה שמקבלת מוצר ומחזירה את רשימת ההלואות שלו
 public IHttpActionResult GetLendings(DTO.ProductToGMH p)
 {
     return(Ok(BL.LendingsBL.GetLendings(p)));
 }
示例#4
0
 [Route("GetImg"), HttpPost]//פונקציה שמחזירה תמונה של מוצר
 public IHttpActionResult GetImg(DTO.ProductToGMH p)
 {
     return(Ok(BL.productsBL.getImages(p)));
 }
示例#5
0
 [Route("Delete"), HttpPost]//פונקציה שמוחקת מוצר
 public IHttpActionResult Delete(DTO.ProductToGMH p)
 {
     return(Ok(BL.productsBL.delete(p)));
 }
示例#6
0
 [Route("SaveChange"), HttpPost]//פונקציה ששומרת שינויים של מוצר
 public IHttpActionResult SaveChange(DTO.ProductToGMH p)
 {
     return(Ok(BL.productsBL.saveChange(p)));
 }
示例#7
0
 public IHttpActionResult getProduct(DTO.ProductToGMH p)
 {
     return(Ok(BL.productsBL.getProduct(p)));
 }