public async Task <BannerVM> GetBannerListAsync(int pageno, int pagesize, string sterm) { BannerVM model = new BannerVM(); var parStart = new SqlParameter("@Start", (pageno - 1) * pagesize); var parEnd = new SqlParameter("@PageSize", pagesize); var parSearchTerm = new SqlParameter("@SearchTerm", DBNull.Value); if (!(sterm == null || sterm == "")) { parSearchTerm.Value = sterm; } // setting stored procedure OUTPUT value // This return total number of rows, and avoid two database call for data and total number of rows var spOutput = new SqlParameter { ParameterName = "@TotalCount", SqlDbType = System.Data.SqlDbType.BigInt, Direction = System.Data.ParameterDirection.Output }; model.BannerList = await objDB.Database.SqlQuery <BannerView>("udspMstBannerList @Start, @PageSize,@SearchTerm, @TotalCount out", parStart, parEnd, parSearchTerm, spOutput).ToListAsync(); model.TotalRecords = int.Parse(spOutput.Value.ToString()); return(model); }
public void Put(Guid id, [FromBody] BannerVM banner) { var b = _uow.Banners.Get(id); b.Name = banner.Name; b.Image = banner.Image; b.Description = banner.Description; _uow.Banners.Update(b); var result = _uow.SaveChanges(); }
public ActionResult BannerList(int PageNo = 1, int PageSize = 10, string SearchTerm = "") { try { ViewBag.ActiveURL = "/Admin/Bannerlist"; string query = "PageNo=" + PageNo + "&PageSize=" + PageSize + "&SearchTerm=" + SearchTerm; BannerAPIVM apiModel = objAPI.GetRecordByQueryString <BannerAPIVM>("configuration", "bannerlist", query); BannerVM model = new BannerVM(); model.BannerList = apiModel.BannerList; model.PagingInfo = new PagingInfo { CurrentPage = PageNo, ItemsPerPage = PageSize, TotalItems = apiModel.TotalRecords }; if (Request.IsAjaxRequest()) { return(PartialView("_pvBannerList", model)); } return(View(model)); } catch (AuthorizationException) { TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again"; return(RedirectToAction("Login", "Account", new { Area = "" })); } }
public IActionResult Save(BannerVM model) { AjaxMessage aMsg = new AjaxMessage(); if (model != null) { if (ModelState.IsValid) { var files = Request.Form.Files; string fileName = Guid.NewGuid().ToString(); if (files.Count > 0) { IFormFile image = files[0]; string imageExtension = Path.GetExtension(image.FileName); string filePath = Path.Combine(_env.WebRootPath, "images\\banner\\"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } using (MagickImage imageFile = new MagickImage(GetFormImageToByte(files[0]))) { imageFile.AutoOrient(); imageFile.Write(Path.Combine(filePath, fileName + imageExtension)); } Banner banner = new Banner(); banner.Description = model.Description; banner.FileName = fileName; banner.FilePath = filePath; banner.OperationDate = DateTime.Now; banner.OperationIdUserRef = HttpRequestInfo.UserID; banner.OperationIP = HttpRequestInfo.IpAddress; banner.OperationIsDeleted = 1; if (model.IdBanner == 0) { _administrationBLLocator.BannerBL.CRUD.Insert(banner); _administrationBLLocator.BannerBL.Save(); aMsg.Status = 1; aMsg.Message = "Kayıt Başarıyla Eklendi."; } else { banner.IdBanner = model.IdBanner; _administrationBLLocator.BannerBL.CRUD.Update(banner, HttpRequestInfo); _administrationBLLocator.BannerBL.Save(); aMsg.Status = 1; aMsg.Message = "Güncelleme Başarılı."; } } } else { aMsg.Status = 0; aMsg.Message = "Bir Hata oluştu"; } } return(Json(aMsg)); }
public void Post([FromBody] BannerVM banner) { _uow.Banners.Add(_mapper.Map <Banner>(banner)); _uow.SaveChanges(); }