Example #1
0
        public PromotionModel GetPromotionDetails(int id)
        {
            ShomaRMEntities db               = new ShomaRMEntities();
            PromotionModel  model            = new PromotionModel();
            var             getPromotiondata = db.tbl_Promotion.Where(p => p.PromotionID == id).FirstOrDefault();

            if (getPromotiondata != null)
            {
                model.PropertyID     = getPromotiondata.PropertyID;
                model.PromotionTitle = getPromotiondata.PromotionTitle;
                model.StartDate      = getPromotiondata.StartDate;
                model.EndDate        = getPromotiondata.EndDate;
            }
            model.PromotionID = id;
            return(model);
        }
Example #2
0
        public List <PromotionModel> GetPromotionListDetails(DateTime FromDate, DateTime ToDate)
        {
            ShomaRMEntities       db    = new ShomaRMEntities();
            List <PromotionModel> lstpr = new List <PromotionModel>();

            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    FromDate = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"));
                    ToDate   = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"));

                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetPromotionList";
                    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)
                {
                    PromotionModel pr = new PromotionModel();
                    pr.PromotionTitle = dr["PromotionTitle"].ToString();
                    lstpr.Add(pr);
                }
                db.Dispose();
                return(lstpr.ToList());
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
Example #3
0
        public string SaveUpdatePromotion(PromotionModel model)
        {
            ShomaRMEntities db     = new ShomaRMEntities();
            string          msg    = "";
            int             userid = ShomaRM.Models.ShomaGroupWebSession.CurrentUser != null ? ShomaRM.Models.ShomaGroupWebSession.CurrentUser.UserID : 0;

            if (model.PromotionID == 0)
            {
                var savePromotion = new tbl_Promotion()
                {
                    PromotionID    = model.PromotionID,
                    PropertyID     = model.PropertyID,
                    PromotionTitle = model.PromotionTitle,
                    StartDate      = model.StartDate,
                    EndDate        = model.EndDate,
                    CreatedDate    = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy")),
                    CreatedById    = userid
                };
                db.tbl_Promotion.Add(savePromotion);
                db.SaveChanges();
                msg = "Promotion Details Saved Successfully";
            }
            else
            {
                var getNOdata = db.tbl_Promotion.Where(p => p.PromotionID == model.PromotionID).FirstOrDefault();
                if (getNOdata != null)
                {
                    getNOdata.PromotionID    = model.PromotionID;
                    getNOdata.PropertyID     = model.PropertyID;
                    getNOdata.PromotionTitle = model.PromotionTitle;
                    getNOdata.StartDate      = model.StartDate;
                    getNOdata.EndDate        = model.EndDate;
                    getNOdata.CreatedDate    = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"));
                    getNOdata.CreatedById    = userid;
                }
                db.SaveChanges();
                msg = "Promotion Details Updated Successfully";
            }
            db.Dispose();
            return(msg);
        }