public ActionResult Save(int? id, string name, string pitch, string price, HttpPostedFileBase photo,
            string returnPolicy, string expDate, string rasiusOfValidity)
        {
            string path = null;
             try
             {
            // Save the photo and its path
            if (photo != null && photo.ContentLength > 0)
            {
               // Save the picture
               path = Server.MapPath(ConfigurationManager.AppSettings["PicturesBaseDir"].ToString());
               path = Path.Combine(path, User.Identity.Name);
               if (!Directory.Exists(path))
                  Directory.CreateDirectory(path);
               path = Path.Combine(path, Guid.NewGuid().ToString() + Path.GetExtension(photo.FileName));
               photo.SaveAs(path);
            }
             }
             catch (Exception)
             {
             }

             // Create or update the deal
             var dao = new DealDao();
             int merchantId = int.Parse(User.Identity.Name);
             var d = id == null ? new dal.linq.Deal() { MerchantId = merchantId } : dao.Get(merchantId);
             dao.SetProperties(name, pitch, price, path, returnPolicy, expDate, rasiusOfValidity, d);

             if (id == null)
            dao.Add(d);
             else
            dao.Update(d);
             return Redirect("/MyDeals");
        }
 public JsonResult GetMyDeals(int page, int pageSize, string sortBy, string sortOrder)
 {
     DateTime now = DateTime.Now;
        int merchantId = int.Parse(User.Identity.Name);
        var gridRows = new DealDao().GetAllNotExpired(merchantId);
        var gridPageJson = new
        {
       total = (gridRows.Count() + pageSize - 1) / pageSize,
       page = page,
       records = gridRows.Count(),
       rows = (from r in gridRows.OrderBy(sortBy + " " + sortOrder).Skip((page - 1) * pageSize).Take(pageSize)
               select new
               {
                  id = r.Id,
                  Category = "Category",
                  Offer = r.Name,
                  Offerers = "Group",
                  Pitch = r.Pitch,
                  Price = "$" + r.Price,
                  Expiration = string.Format("{0:0.0}", (r.ExpirationDate.Value - now).TotalHours)
               }).ToArray()
        };
        return Json(gridPageJson, JsonRequestBehavior.AllowGet);
 }