// GET: PMS/BGs public ActionResult BGsData(int?id) { List <FilterEntity> listFilters = _filterService.GetFilters(); //listFilters.Add(new FilterEntity { FilterCode = "1", FilterName = "pc1", FilterType = "ProjectCode" }); //listFilters.Add(new FilterEntity { FilterCode = "2", FilterName = "pc2", FilterType = "ProjectCode" }); listFilters.Add(new FilterEntity { FilterCode = "11", FilterName = "t1", FilterType = "TypeofBG" }); listFilters.Add(new FilterEntity { FilterCode = "22", FilterName = "t2", FilterType = "TypeofBG" }); ViewBag.Filters = listFilters; tblBGsData bgsData = null; if (id == null) { bgsData = new tblBGsData(); } else { bgsData = _bgsService.Get(id.Value); } return(View(bgsData)); }
public JsonResult SaveBGs() { int result = 0; tblBGsData data = JsonConvert.DeserializeObject <tblBGsData>(Request["data"]); if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; HttpPostedFileBase file = files[0]; string folderPath = ConfigurationManager.AppSettings["BGsPath"]; string fileName = ""; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } if (data.IsFileAttached) { fileName = DateTime.Now.ToString("ddMMyyyHHmmsss") + "_" + Request.Files[0].FileName; if (!string.IsNullOrEmpty(data.FilePath) && data.IsFileAttached) { System.IO.File.Delete(data.FilePath); } if (!System.IO.File.Exists(folderPath + fileName)) { Request.Files[0].SaveAs(folderPath + fileName); data.FilePath = folderPath + fileName; data.FileName = fileName; } else { fileName = DateTime.Now.ToString("ddMMyyyHHmmsss") + "_1_" + Request.Files[0].FileName; Request.Files[0].SaveAs(folderPath + fileName); data.FilePath = folderPath + fileName; data.FileName = fileName; } } } if (data.Id == 0) { result = _bgsService.Insert(data); } else { result = _bgsService.Update(data); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public tblBGsData Get(int id) { tblBGsData data = null; try { using (var dbContext = new PMSEntities()) { data = dbContext.tblBGsDatas.Where(x => x.Id == id).ToList().FirstOrDefault(); } } catch (Exception ex) { } return(data); }
public int Update(tblBGsData data) { try { using (var dbContext = new PMSEntities()) { dbContext.tblBGsDatas.Attach(data); dbContext.Entry(data).State = EntityState.Modified; dbContext.SaveChanges(); } return(1); } catch (Exception ex) { return(0); } }
public int Insert(tblBGsData data) { try { using (var dbContext = new PMSEntities()) { data.BGsId = Guid.NewGuid(); dbContext.tblBGsDatas.Add(data); dbContext.SaveChanges(); } return(1); } catch (Exception ex) { return(0); } }
public int Update(tblBGsData data) { return(_bgsRepository.Update(data)); }
public int Insert(tblBGsData data) { return(_bgsRepository.Insert(data)); }