public JsonResult GetStrategic(long id) { try { Strategic strategic = Strategic.Get(SessionContext, id); if (strategic == null) { SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Get, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } StrategicViewModel strategicViewModel = new StrategicViewModel { ID = strategic.ID, Name = strategic.Name, }; return(Json(new { Success = true, strategicViewModel }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Get, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } }
public void Get_Test() { //Arrage var strategic = Strategic.Get(context, 1L); //Act long id = 1L; //Assert Assert.AreEqual(strategic.ID, id); }
public JsonResult Update(long id, string name) { try { if (string.IsNullOrEmpty(name)) { SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Update, MessageException.Fail("The name is emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } Strategic strategic = Strategic.Get(SessionContext, id); if (strategic == null) { return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { strategic.Name = name; //strategic.EffectivePeriod.From = DateTime.Now; strategic.UpdateAction = new UserAction(SessionContext.User); strategic.EffectivePeriod = TimeInterval.EffectiveNow; strategic.Persist(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Update, MessageException.Success(id.ToString())); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.StrategicMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.StrategicMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "แก้ไขนโยบายเชิงยุทธศาสตร์ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateDetail(long pId, string projectName, int strategicId, string year, string budget, string expenditure) { Project project = null; string projectIdEncryp = string.Empty; if (string.IsNullOrEmpty(projectName) || strategicId <= 0 || string.IsNullOrEmpty(year) || string.IsNullOrEmpty(budget) || string.IsNullOrEmpty(expenditure)) { SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateDetail, MessageException.Null("There are input project detail emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { project = SessionContext.PersistenceSession.Get <Project>(pId); project.Name = projectName; project.Strategic = Strategic.Get(SessionContext, strategicId); project.BudgetYear = year; project.BudgetAmount = decimal.Parse(budget); project.BudgetType = (BudgetType)Enum.Parse(typeof(BudgetType), expenditure); project.CreateAction = new iSabaya.UserAction(SessionContext.User); project.StatusCategory = StatusCategory.Update; project.Status = Status.SaveDeail; SessionContext.Persist(project); tx.Commit(); SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateDetail, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.PageID, 0, MessageException.ProjectMessage.UpdateDetail, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, Message = "บันทึก ข้อมูลรายละเอียดโครงการ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(long id) { try { Strategic strategic = Strategic.Get(SessionContext, id); if (strategic == null) { SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { strategic.EffectivePeriod = new TimeInterval(TimeInterval.MaxDate, TimeInterval.MinDate); strategic.UpdateAction = new UserAction(SessionContext.User); //strategic.Delete(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Success(id.ToString())); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "ลบนโยบายเชิงยุทธศาสตร์ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }