Beispiel #1
0
        public static int UpdateMappedRooms(etblPropetyPhotoMap etblPropetyPhotoMap)
        {
            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var idParam = new SqlParameter[6];
                idParam[0] = new SqlParameter("iPhotoId", etblPropetyPhotoMap.iPhotoId);
                idParam[1] = new SqlParameter("iPropId", etblPropetyPhotoMap.iPropId);
                idParam[2] = new SqlParameter("iPhotoCatId", etblPropetyPhotoMap.iPhotoCatId);
                idParam[3] = new SqlParameter("iPhotoSubCatId", etblPropetyPhotoMap.iPhotoSubCatId);
                idParam[4] = new SqlParameter("bIsPrimary", etblPropetyPhotoMap.bIsPrimaryR);
                idParam[5] = new SqlParameter("iActionBy", etblPropetyPhotoMap.iActionBy);

                var objTblRatePlan = db.Database.ExecuteSqlCommand("spSetPrimaryR_False @iPhotoId, @iPropId, @iPhotoCatId,@iPhotoSubCatId,@bIsPrimary,@iActionBy", idParam);
                return(1);
            }
        }
Beispiel #2
0
        public static etblPropetyPhotoMap GetRecordById(long photoMapId)
        {
            etblPropetyPhotoMap etblPropetyPhotoMap = null;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    var eobj = db.tblPropertyPhotoMaps.Where(x => x.iPhotoId == photoMapId).FirstOrDefault();

                    etblPropetyPhotoMap = (etblPropetyPhotoMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new etblPropetyPhotoMap());
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(etblPropetyPhotoMap);
        }
Beispiel #3
0
        public static int AddRecord(etblPropetyPhotoMap eobj)
        {
            int statusCode = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    OneFineRate.tblPropertyPhotoMap dbuser = (OneFineRate.tblPropertyPhotoMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyPhotoMap());
                    db.tblPropertyPhotoMaps.Add(dbuser);
                    db.SaveChanges();
                    statusCode = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(statusCode);
        }
Beispiel #4
0
        public static int UpdateRecord(etblPropetyPhotoMap eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    OneFineRate.tblPropertyPhotoMap obj = (OneFineRate.tblPropertyPhotoMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyPhotoMap());
                    db.tblPropertyPhotoMaps.Attach(obj);
                    db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }
        public ActionResult UpdatePropertyPhotoMap(etblPropetyPhotoMap etblPropetyPhotoMap, long?roomId)
        {
            try
            {
                bool   status = false;
                string msg    = string.Empty;
                int    result = -1;

                var userId = Convert.ToInt32(((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId);
                etblPropetyPhotoMap.iActionBy = userId;

                if (roomId.HasValue)
                {
                    result = BL_tblPropertyPhotoMap.UpdateMappedRooms(etblPropetyPhotoMap);
                }
                else
                {
                    result = BL_tblPropertyPhotoMap.UpdateMappedProeprty(etblPropetyPhotoMap);
                }

                if (result == 1)
                {
                    TempData["msg"] = "Photo Mapping updated successfully!";
                    msg             = "Photo Mapping updated successfully!";
                    status          = true;
                }
                else
                {
                    TempData["ERROR"] = "Sorry! Something went wrong, Please try refreshing the page.";
                    msg = "Sorry! Something went wrong, Please try refreshing the page.";
                }
                var jsonResult = Json(new { status = status, msg = msg }, JsonRequestBehavior.AllowGet);
                return(jsonResult);
            }
            catch (Exception e)
            {
                var jsonResult = Json(new { status = false, msg = e.Message }, JsonRequestBehavior.AllowGet);
                return(jsonResult);
            }
        }
        public ActionResult Index(IEnumerable <HttpPostedFileBase> photos)
        {
            try
            {
                bool isSavedSuccessfully = false;
                if (photos != null)
                {
                    if (Session["PropId"] != null)
                    {
                        var propertyId = Convert.ToInt32(Session["PropId"].ToString());

                        IList <etblPropetyPhotoMap> etblPropetyImageMList = new List <etblPropetyPhotoMap>();

                        string s_propertyId = propertyId.ToString();

                        //if(propertyId < 10)
                        //{
                        //    s_propertyId = "00" + propertyId.ToString();
                        //}
                        //else if(propertyId < 100)
                        //{
                        //    s_propertyId = "0" + propertyId.ToString();
                        //}

                        foreach (var uploadedFile in photos)
                        {
                            if (IsValideImage(uploadedFile))
                            {
                                using (MemoryStream target = new MemoryStream())
                                {
                                    uploadedFile.InputStream.CopyTo(target);
                                    byte[] data = target.ToArray();

                                    var uniqueFileName = Guid.NewGuid().ToString() + Path.GetExtension(uploadedFile.FileName);

                                    var currentUploadedFileUrl = clsUtils.fnUploadFileINBlobStorage(s_propertyId, uniqueFileName, data, true);

                                    System.Drawing.Image image = System.Drawing.Image.FromStream(new System.IO.MemoryStream(data));

                                    var etblPropertyPhotoMap = new etblPropetyPhotoMap();
                                    etblPropertyPhotoMap.iPropId             = propertyId;
                                    etblPropertyPhotoMap.bIsMapped           = false;
                                    etblPropertyPhotoMap.sImgUrl             = propertyId.ToString() + "/" + uniqueFileName;
                                    etblPropertyPhotoMap.UniqueAzureFileName = uniqueFileName;
                                    etblPropertyPhotoMap.dtActionDate        = DateTime.Now;
                                    etblPropertyPhotoMap.iActionBy           = Convert.ToInt16(((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId);

                                    if (image.Height >= 1080 && image.Width >= 1360)
                                    {
                                        etblPropertyPhotoMap.bIsHighRes = true;
                                    }
                                    else
                                    {
                                        etblPropertyPhotoMap.bIsHighRes = false;
                                    }
                                    etblPropertyPhotoMap.iResolutionH = (short)image.Height;
                                    etblPropertyPhotoMap.iResolutionW = (short)image.Width;

                                    etblPropetyImageMList.Add(etblPropertyPhotoMap);
                                }
                            }
                            else
                            {
                                TempData["ERROR"] = "Invalid Images ! Please upload only .jpg, .png, .jpeg or .bmp images";
                                return(View());
                            }
                        }
                        BL_tblPropertyPhotoMap.AddMultipleRecord(etblPropetyImageMList.ToArray());
                        isSavedSuccessfully = true;
                    }
                    if (isSavedSuccessfully)
                    {
                        TempData["msg"] = "Photos uploaded successfully !";
                        return(Json(new { Message = "Files uploaded successfully !" }));
                    }
                    else
                    {
                        return(Json(new { status = "error", Message = "Error in saving file" }));
                    }
                }
                return(View());
            }
            catch (Exception ex)
            {
                TempData["ERROR"] = ex.Message;
                return(Json(new { Message = ex.Message }));
            }
        }