Exemplo n.º 1
0
        public ActionResult Add(VMCampaignAdd model, HttpPostedFileBase file, string MakeID, string StartedDate, int EndingDate)
        {
            Campaign campaign = new Campaign();

            campaign.CampaignID  = Guid.NewGuid();
            campaign.Title       = model.Campaign.Title;
            campaign.StartedDate = DateTime.Parse(StartedDate);
            campaign.EndingDate  = campaign.StartedDate.AddDays(EndingDate);
            campaign.Discount    = model.Campaign.Discount;
            campaign.Status      = model.Campaign.Status;
            campaign.IsActive    = true;
            if (file != null && file.ContentLength > 0)
            {
                string path = Path.Combine(Server.MapPath("~/Assets/img/campaign"), Path.GetFileName(file.FileName));
                file.SaveAs(path);
                campaign.PictureUrl = Path.GetFileName(file.FileName);
            }
            Category cat  = CategoryDAL.Get();
            Guid     temp = Guid.Parse(MakeID);
            Make     make = MakeDAL.Get(x => x.MakeID == temp);

            foreach (var m in make.Models)
            {
                foreach (var p in m.Products)
                {
                    campaign.Products.Add(p);
                }
            }

            CampaignDAL.Add(campaign);

            return(RedirectToAction("Index", "Campaign"));
        }
Exemplo n.º 2
0
        public ActionResult GetListReopenCampaign(int pageIndex, string pageSize, ListFilterParam list, string filter = "")
        {
            filter = filter.Replace("!!", "%");
            var db = new CampaignDAL();

            ViewBag.pageIndex = pageIndex;
            ViewBag.pageSize  = pageSize;
            int?total = 0;

            if (list.filter7 == "1" && filter.Split('=').Count() > 1)
            {
                filter = filter.Replace(filter.Split('=')[filter.Split('=').Count() - 1], "1");
            }
            TableColumnsTotal totalColumns = new TableColumnsTotal();
            var baseListParam = new BaseListParam()
            {
                FilterField  = filter,
                OrderByField = "",
                UserType     = Global.CurrentUser.RoleId,
                UserId       = Global.CurrentUser.LoginUserId,
                DeptId       = Global.CurrentUser.OrganizationUnitID,
                PageIndex    = pageIndex,
                PageSize     = Int32.Parse(pageSize),
                LanguageCode = Global.CurrentUser.CurrentLanguageID.ToString()
            };
            var result = db.GetListReopenCampaign(baseListParam, list, out total);

            return(Content(JsonConvert.SerializeObject(new
            {
                employees = result,
                totalCount = total,
                lstTotal = totalColumns,
                userid = baseListParam.UserId
            })));
        }
Exemplo n.º 3
0
 public virtual void Update(CampaignDataModel campaign)
 {
     if (campaign.ID > 0)
     {
         CampaignDAL.Update(campaign);
     }
     else
     {
         throw new Exception("Page not found");
     }
 }
Exemplo n.º 4
0
 public virtual void Create(CampaignDataModel campaign)
 {
     CampaignDAL.Create(campaign);
 }
Exemplo n.º 5
0
 public CampaignDataModel Get(int id)
 {
     return(CampaignDAL.Get(id));
 }
Exemplo n.º 6
0
 public List <CampaignDataModel> GetAll()
 {
     return(CampaignDAL.GetAll());
 }
Exemplo n.º 7
0
 public List <ActivityDataModel> GetCampaignActivities(int id)
 {
     return(CampaignDAL.GetCampaignActivities(id));
 }
Exemplo n.º 8
0
 // GET: Admin/Campaign
 public ActionResult Index()
 {
     return(View(CampaignDAL.GetList()));
 }
Exemplo n.º 9
0
        public ActionResult ExportListReopenCampaign(int pageIndex, int pageSize, ListFilterParam list, string filter = "")
        {
            filter = filter.Replace("!!", "%");
            DataTable dt = new DataTable("Grid");

            dt.Columns.AddRange(new DataColumn[6]
            {
                new DataColumn(AppRes.ErpCampaignID),
                new DataColumn(AppRes.ReopenBy),
                new DataColumn(AppRes.OrganizationUnit),
                new DataColumn(AppRes.ReasonReopenCampaign),
                new DataColumn(AppRes.MediaAccount),
                new DataColumn(AppRes.TimeReopenCampaign)
            });
            dt.Columns[0].DataType = typeof(string);
            dt.Columns[1].DataType = typeof(string);
            dt.Columns[2].DataType = typeof(string);
            dt.Columns[3].DataType = typeof(string);
            dt.Columns[4].DataType = typeof(string);
            dt.Columns[5].DataType = typeof(DateTime);


            var db            = new CampaignDAL();
            int?total         = 0;
            var baseListParam = new BaseListParam()
            {
                FilterField  = filter,
                OrderByField = "",
                UserType     = Global.CurrentUser.RoleId,
                UserId       = Global.CurrentUser.LoginUserId,
                DeptId       = Global.CurrentUser.OrganizationUnitID,
                LanguageCode = Global.CurrentUser.CurrentLanguageID.ToString()
            };

            list.FromDate = Convert.ToDateTime(DateTime.ParseExact(list.StringFromDate, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture));
            list.ToDate   = Convert.ToDateTime(DateTime.ParseExact(list.StringToDate, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture));
            var lstData = db.ExportListReopenCampaign(baseListParam, list, out total);

            foreach (var item in lstData)
            {
                dt.Rows.Add(
                    item.CampaignId == null ? "" : item.CampaignId,
                    item.ReopenBy == null ? "" : item.ReopenBy,
                    item.OrginizationUnit == null ? "" : item.OrginizationUnit,
                    item.Reason == null ? "" : item.Reason,
                    item.Requester == null ? "" : item.Requester,
                    item.ReopenDate == null ? new DateTime(1, 1, 1) : item.ReopenDate
                    );
            }

            var wb = new XLWorkbook();

            wb.Worksheets.Add(dt);
            byte[] data = null;
            using (var stream = new MemoryStream())
            {
                wb.SaveAs(stream);
                data = stream.ToArray();
            }
            var excelName = "";

            excelName = "ListCampaignReopen.xlsx";
            return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName));
        }