Example #1
0
        public List <AmenitiesSlotModel> GetSlotListData(DateTime FromDate, DateTime ToDate)
        {
            ShomaRMEntities           db    = new ShomaRMEntities();
            List <AmenitiesSlotModel> lstpr = new List <AmenitiesSlotModel>();

            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetAmenitySlotList";
                    cmd.CommandType = CommandType.StoredProcedure;

                    DbParameter paramF = cmd.CreateParameter();
                    paramF.ParameterName = "FromDate";
                    paramF.Value         = FromDate;
                    cmd.Parameters.Add(paramF);

                    DbParameter paramC = cmd.CreateParameter();
                    paramC.ParameterName = "ToDate";
                    paramC.Value         = ToDate;
                    cmd.Parameters.Add(paramC);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                foreach (DataRow dr in dtTable.Rows)
                {
                    AmenitiesSlotModel pr = new AmenitiesSlotModel();


                    pr.AmenityID = Convert.ToInt64(dr["AmenityID"].ToString());
                    pr.Duration  = dr["Duration"].ToString();
                    pr.Deposit   = Convert.ToDecimal(dr["Deposit"].ToString());
                    pr.Fees      = Convert.ToDecimal(dr["Deposit"].ToString());
                    lstpr.Add(pr);
                }
                db.Dispose();
                return(lstpr.ToList());
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
Example #2
0
        public AmenitiesSlotModel GetEventData(int Id)
        {
            ShomaRMEntities    db    = new ShomaRMEntities();
            AmenitiesSlotModel model = new AmenitiesSlotModel();

            var GetSlotData = db.tbl_AmenityPriceRange.Where(p => p.ID == Id).FirstOrDefault();

            if (GetSlotData != null)
            {
                model.AmenityID  = GetSlotData.AmenityID;
                model.Duration   = GetSlotData.Duration;
                model.Deposit    = GetSlotData.Deposit;
                model.Fees       = GetSlotData.Fees;
                model.DurationID = Convert.ToInt64(GetSlotData.DurationID);
            }
            model.ID = Id;
            return(model);
        }
Example #3
0
        public string SaveUpdateSlot(AmenitiesSlotModel model)
        {
            string          msg = "";
            ShomaRMEntities db  = new ShomaRMEntities();

            if (model.ID == 0)
            {
                var saveSlot = new tbl_AmenityPriceRange()
                {
                    AmenityID  = model.AmenityID,
                    Duration   = model.Duration,
                    Deposit    = model.Deposit,
                    Fees       = model.Fees,
                    DurationID = model.DurationID
                };
                db.tbl_AmenityPriceRange.Add(saveSlot);
                db.SaveChanges();
                msg = "Amenity Slot Save Successfully";
            }
            else
            {
                var GetSlotData = db.tbl_AmenityPriceRange.Where(p => p.ID == model.ID).FirstOrDefault();
                if (GetSlotData != null)
                {
                    GetSlotData.AmenityID  = model.AmenityID;
                    GetSlotData.Duration   = model.Duration;
                    GetSlotData.Deposit    = model.Deposit;
                    GetSlotData.Fees       = model.Fees;
                    GetSlotData.DurationID = model.DurationID;
                    db.SaveChanges();
                    msg = "Amenity Slot Updated Successfully";
                }
            }
            db.Dispose();
            return(msg);
        }