Example #1
0
    // Method for adding an image for a user vehicle.
    //
    public bool AddVehicleImage(string imgUrl, Guid veId, bool isMain)
    {
        using (SwapEntities myEnt = new SwapEntities())
        {
            var coungImgs = (from tbl in myEnt.VeImages
                             where tbl.VehicleId == veId
                             select tbl).Count();

            if (coungImgs < 3)
            {
                var  imgTbl = new VeImage();
                Guid id     = Guid.NewGuid();
                imgTbl.Id        = id;
                imgTbl.VehicleId = veId;
                imgTbl.ImageUrl  = imgUrl;
                imgTbl.IsMain    = isMain;

                myEnt.AddToVeImages(imgTbl);
                myEnt.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }