public static bool UpdateProjectJSON(long Id, string Code, string Name, string Description, string StartDate, string EndDate, long IdStatus) { // Parse date with custom specifier. CultureInfo provider = CultureInfo.InvariantCulture; DateTime StartDateDT; DateTime? EndDateDT = null; StartDateDT = DateTime.ParseExact(StartDate, "dd-mm-yyyy", provider); if (EndDate.Length > 0) { EndDateDT = DateTime.ParseExact(EndDate, "dd-mm-yyyy", provider); } Project project; using (var objCtx = new PWMEntities()) { project = objCtx.Project.SingleOrDefault(x => x.Id == Id); project.Code = Code; project.Name = Name; project.Description = Description; project.StartDate = StartDateDT; project.EndDate = EndDateDT; project.IdStatus = IdStatus; objCtx.SaveChanges(); } return(true); }
public static string LoginJSON(string Login, string Password, bool Persistable) { using (var objCtx = new PWMEntities()) { var resource = from u in objCtx.Resource where (u.Login.ToLower() == Login.ToLower()) && (u.Password == Password) select new { Id = u.Id, Login = u.Login, Name = u.Name, IdStatus = u.IdStatus }; string json = null; if (resource.ToList().Count() > 0) { HttpCookie authCookie = FormsAuthentication.GetAuthCookie(Login, Persistable); if (!Persistable) { //this is because if it was not set then it got //automatically set to expire next year even if //the cookie was not set as persistent authCookie.Expires = DateTime.Now.AddMinutes(60); } HttpContext.Current.Response.Cookies.Add(authCookie); /*FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Login, DateTime.Now, DateTime.Now.AddMinutes(60), Persistable, "member"); * HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); * HttpContext.Current.Response.Cookies.Add(cookie);*/ json = JsonConvert.SerializeObject(resource.ToList()[0]); } return(json); } }
public static long InsertProjectJSON(string Code, string Name, string Description, string StartDate, string EndDate, long IdStatus) { // Parse date with custom specifier. CultureInfo provider = CultureInfo.InvariantCulture; DateTime StartDateDT; DateTime? EndDateDT = null; StartDateDT = DateTime.ParseExact(StartDate, "dd-mm-yyyy", provider); if (EndDate.Length > 0) { EndDateDT = DateTime.ParseExact(EndDate, "dd-mm-yyyy", provider); } Project project = new Project() { Code = Code, Name = Name, Description = Description, StartDate = StartDateDT, EndDate = EndDateDT, IdStatus = IdStatus }; using (var objCtx = new PWMEntities()) { objCtx.Project.AddObject(project); objCtx.SaveChanges(); } return(project.Id); }
public static bool DeleteSessionsJSON(string Ids) { using (var objCtx = new PWMEntities()) { objCtx.ExecuteStoreCommand("DELETE FROM Session WHERE Id IN (" + Ids + ")"); objCtx.SaveChanges(); } return(true); }
public static bool DeleteParameterJSON(int Id) { Parameter parameter; using (var objCtx = new PWMEntities()) { parameter = objCtx.Parameter.SingleOrDefault(x => x.Id == Id); objCtx.Parameter.DeleteObject(parameter); objCtx.SaveChanges(); } return(true); }
public static bool DeleteTaskJSON(int Id) { Task Task; using (var objCtx = new PWMEntities()) { Task = objCtx.Task.SingleOrDefault(x => x.Id == Id); objCtx.Task.DeleteObject(Task); objCtx.SaveChanges(); } return(true); }
public static bool DeleteProjectJSON(long Id) { Project project; using (var objCtx = new PWMEntities()) { project = objCtx.Project.SingleOrDefault(x => x.Id == Id); objCtx.Project.DeleteObject(project); objCtx.SaveChanges(); } return(true); }
public static bool DeleteNoteJSON(int Id) { Note Note; using (var objCtx = new PWMEntities()) { Note = objCtx.Note.SingleOrDefault(x => x.Id == Id); objCtx.Note.DeleteObject(Note); objCtx.SaveChanges(); } return(true); }
public static bool DeleteStatusJSON(int Id) { Status Status; using (var objCtx = new PWMEntities()) { Status = objCtx.Status.SingleOrDefault(x => x.Id == Id); objCtx.Status.DeleteObject(Status); objCtx.SaveChanges(); } return(true); }
public static bool DeleteSessionJSON(int Id) { Session Session; using (var objCtx = new PWMEntities()) { Session = objCtx.Session.SingleOrDefault(x => x.Id == Id); objCtx.Session.DeleteObject(Session); objCtx.SaveChanges(); } return(true); }
public static bool DeleteResourceJSON(int Id) { Resource Resource; using (var objCtx = new PWMEntities()) { Resource = objCtx.Resource.SingleOrDefault(x => x.Id == Id); objCtx.Resource.DeleteObject(Resource); objCtx.SaveChanges(); } return(true); }
public static bool DeleteAlertJSON(int Id) { Alert Alert; using (var objCtx = new PWMEntities()) { Alert = objCtx.Alert.SingleOrDefault(x => x.Id == Id); objCtx.Alert.DeleteObject(Alert); objCtx.SaveChanges(); } return(true); }
public static bool UpdateNoteJSON(int Id, string Text, int IdProject) { Note Note; using (var objCtx = new PWMEntities()) { Note = objCtx.Note.SingleOrDefault(x => x.Id == Id); Note.Text = Text; Note.IdProject = IdProject; objCtx.SaveChanges(); } return(true); }
public static bool UpdateSessionJSON(int Id, string StartTime, string EndTime, long IdTask, long IdResource) { Session Session; using (var objCtx = new PWMEntities()) { Session = objCtx.Session.SingleOrDefault(x => x.Id == Id); Session.StartTime = DateTime.Parse(StartTime); Session.EndTime = DateTime.Parse(EndTime); objCtx.SaveChanges(); } return(true); }
public void InitDataBase() { // Iniciar a base de dados com os dados minimos using (var objCtx = new PWMEntities()) { // Statuss: Status Status = null; var Statuss = from t in objCtx.Status select t; if (Statuss.Count <Status>() == 0) { Status = new Status() { Name = "Activo", Description = "Activo", IdStatusType = (long)StatusTypes.Project }; objCtx.Status.AddObject(Status); Status = new Status() { Name = "Activo", Description = "Activo", IdStatusType = (long)StatusTypes.Task }; objCtx.Status.AddObject(Status); Status = new Status() { Name = "Activo", Description = "Activo", IdStatusType = (long)StatusTypes.Alert }; objCtx.Status.AddObject(Status); Status = new Status() { Name = "Activo", Description = "Activo", IdStatusType = (long)StatusTypes.Resource }; objCtx.Status.AddObject(Status); objCtx.SaveChanges(); } // Utilizadores Resource Resource = null; var Resources = from t in objCtx.Resource select t; if (Resources.Count <Resource>() == 0) { Resource = new Resource() { Login = "******", Name = "Admin", Password = string.Empty, IdStatus = (long)StatusTypes.Resource }; objCtx.Resource.AddObject(Resource); objCtx.SaveChanges(); } } }
public static long InsertParameterJSON(string Name, string Value, string Description) { Parameter parameter = new Parameter() { Name = Name, Value = Value, Description = Description }; using (var objCtx = new PWMEntities()) { objCtx.Parameter.AddObject(parameter); objCtx.SaveChanges(); } return(parameter.Id); }
public static long InsertTaskJSON(string Name, string Description, int Order, int IdProject, int IdStatus) { Task Task = new Task() { Name = Name, Description = Description, Order = Order, IdProject = IdProject, IdStatus = IdStatus }; using (var objCtx = new PWMEntities()) { objCtx.Task.AddObject(Task); objCtx.SaveChanges(); } return(Task.Id); }
public static long InsertResourceJSON(string Login, string Name, string Password, int IdStatus) { Resource Resource = new Resource() { Login = Login, Name = Name, Password = Password, IdStatus = IdStatus }; using (var objCtx = new PWMEntities()) { objCtx.Resource.AddObject(Resource); objCtx.SaveChanges(); } return(Resource.Id); }
public static long InsertSessionJSON(string StartTime, string EndTime, long IdTask, long IdResource) { Session Session = new Session() { StartTime = DateTime.Parse(StartTime), EndTime = DateTime.Parse(EndTime), IdTask = IdTask, IdResource = IdResource }; using (var objCtx = new PWMEntities()) { objCtx.Session.AddObject(Session); objCtx.SaveChanges(); } return(Session.Id); }
public static long InsertStatusJSON(string Name, string Description, int IdStatusType, int Order) { Status Status = new Status() { Name = Name, Description = Description, IdStatusType = IdStatusType, Order = Order }; using (var objCtx = new PWMEntities()) { objCtx.Status.AddObject(Status); objCtx.SaveChanges(); } return(Status.Id); }
public static long InsertNoteJSON(string Text, int IdProject) { Note Note = new Note() { Text = Text, IdProject = IdProject }; using (var objCtx = new PWMEntities()) { objCtx.Note.AddObject(Note); objCtx.SaveChanges(); } return(Note.Id); }
public static long InsertAlertJSON(string Name, string Description, string DueDate, int IdProject) { Alert Alert = new Alert() { Name = Name, Description = Description, DueDate = DateTime.Parse(DueDate), IdProject = IdProject }; using (var objCtx = new PWMEntities()) { objCtx.Alert.AddObject(Alert); objCtx.SaveChanges(); } return(Alert.Id); }
public static bool UpdateParameterJSON(int Id, string Name, string Value, string Description) { Parameter parameter; using (var objCtx = new PWMEntities()) { parameter = objCtx.Parameter.SingleOrDefault(x => x.Id == Id); parameter.Name = Name; parameter.Value = Value; parameter.Description = Description; objCtx.SaveChanges(); } return(true); }
public static bool UpdateResourceJSON(int Id, string Login, string Name, string Password, int IdStatus) { Resource Resource; using (var objCtx = new PWMEntities()) { Resource = objCtx.Resource.SingleOrDefault(x => x.Id == Id); Resource.Login = Login; Resource.Name = Name; Resource.Password = Password; Resource.IdStatus = IdStatus; objCtx.SaveChanges(); } return(true); }
public static string GetStatusStatusTypesJSON() { using (var objCtx = new PWMEntities()) { var records = from e in objCtx.StatusType orderby e.Id ascending select new { Id = e.Id, Name = e.Name }; string json = JsonConvert.SerializeObject(records); return(json); } }
public static string GetSessionResourcesJSON(long IdProject) { using (var objCtx = new PWMEntities()) { var records = from r in objCtx.Resource join e in objCtx.Status on r.IdStatus equals e.Id select new { Id = r.Id, Name = r.Name }; string json = JsonConvert.SerializeObject(records); return(json); } }
public static bool UpdateStatusJSON(int Id, string Name, string Description, int IdStatusType, int Order) { Status Status; using (var objCtx = new PWMEntities()) { Status = objCtx.Status.SingleOrDefault(x => x.Id == Id); Status.Name = Name; Status.Description = Description; Status.IdStatusType = IdStatusType; Status.Order = Order; objCtx.SaveChanges(); } return(true); }
public static string GetNotesJSON(long IdProject) { using (var objCtx = new PWMEntities()) { var records = from t in objCtx.Note where t.IdProject == IdProject select new { Id = t.Id, Text = t.Text }; string json = JsonConvert.SerializeObject(records); return(json); } }
public static string GetProjectStatusesJSON() { using (var objCtx = new PWMEntities()) { var records = from e in objCtx.Status where e.IdStatusType.Equals((long)DBUtil.StatusTypes.Project) select new { Id = e.Id, Name = e.Name }; string json = JsonConvert.SerializeObject(records); return(json); } }
public static bool UpdateAlertJSON(int Id, string Name, string Description, string DueDate, int IdProject) { Alert Alert; using (var objCtx = new PWMEntities()) { Alert = objCtx.Alert.SingleOrDefault(x => x.Id == Id); Alert.Name = Name; Alert.Description = Description; Alert.DueDate = DateTime.Parse(DueDate); Alert.IdProject = IdProject; objCtx.SaveChanges(); } return(true); }