public List <ProExclusiveModel> GetProExclusives() { var proExclusiveModels = new List <ProExclusiveModel>(); var proExclusives = _db.ProExclusives.ToList(); foreach (var proExclusive in proExclusives) { var proExclusiveModel = new ProExclusiveModel() { ProExclusiveId = proExclusive.ProExclusiveId, CompanyId = proExclusive.CompanyId, CompanyName = proExclusive.CompanyName, PDFFilePath = proExclusive.PDFFilePath, PDFTitle = proExclusive.PDFTitle, ThumbnailPath = proExclusive.ThumbnailPath, ValidFrom = proExclusive.ValidFrom, ValidTill = proExclusive.ValidTill, CreatedBy = proExclusive.CreatedBy, CreatedDate = proExclusive.CreatedDate, ModifiedBy = proExclusive.ModifiedBy, ModifiedDate = proExclusive.ModifiedDate }; proExclusiveModels.Add(proExclusiveModel); } return(proExclusiveModels); }
public JsonResult SaveProExclusive(string strProExclusive) { var serializer = new JavaScriptSerializer(); var proExclusiveModel = serializer.Deserialize(strProExclusive, typeof(ProExclusiveModel)); ProExclusiveModel model = (dynamic)(proExclusiveModel); ProExclusive _ProExclusive = new ProExclusive(); if (_ProExclusive.ProExclusiveId > 0) { _ProExclusive = _db.ProExclusives.FirstOrDefault(a => a.ProExclusiveId == model.ProExclusiveId); _ProExclusive.ModifiedDate = DateTime.Now; _ProExclusive.ModifiedBy = 1; // To-Do : Pass Logged In Users Id model.ModifiedDate = DateTime.Now; model.ModifiedBy = 1; // To-Do : Pass Logged In Users Id } else { _ProExclusive.CreatedDate = DateTime.Now; _ProExclusive.CreatedBy = 1; // To-Do : Pass Logged In Users Id model.CreatedDate = DateTime.Now; model.CreatedBy = 1; // To-Do : Pass Logged In Users Id } _ProExclusive.CompanyId = model.CompanyId; _ProExclusive.CompanyName = model.CompanyName; _ProExclusive.ThumbnailPath = "http://psgapp.proforma.com//Uploads/" + model.ThumbnailPath; _ProExclusive.PDFTitle = model.PDFTitle; _ProExclusive.PDFFilePath = "http://psgapp.proforma.com//Uploads/" + model.PDFFilePath; _ProExclusive.ValidFrom = DateTime.Now; model.ValidFrom = DateTime.Now; _ProExclusive.ValidTill = model.ValidTill; if (model.ProExclusiveId > 0) { _db.Entry(_ProExclusive).State = EntityState.Modified; } else { _db.ProExclusives.Add(_ProExclusive); } _db.SaveChanges(); model.Message = "Success"; return(Json(model, JsonRequestBehavior.AllowGet)); }