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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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); }
public static bool UpdateTaskJSON(int Id, string Name, string Description, int Order, int IdProject, int IdStatus) { Task Task; using (var objCtx = new PWMEntities()) { Task = objCtx.Task.SingleOrDefault(x => x.Id == Id); Task.Name = Name; Task.Description = Description; Task.Order = Order; Task.IdProject = IdProject; Task.IdStatus = IdStatus; objCtx.SaveChanges(); } return(true); }
public static long InsertProjectJSON(string Code, string Name, string Description, string StartDate, string EndDate, long IdStatus) { DateTime?EndDateDT = null; if (!string.IsNullOrEmpty(EndDate) && (EndDate.Length > 0)) { EndDateDT = DateTime.Parse(EndDate); } Project project = new Project() { Code = Code, Name = Name, Description = Description, StartDate = DateTime.Parse(StartDate), EndDate = EndDateDT, IdStatus = IdStatus }; using (var objCtx = new PWMEntities()) { objCtx.Project.AddObject(project); objCtx.SaveChanges(); } return(project.Id); }
public static bool UpdateProjectJSON(long Id, string Code, string Name, string Description, string StartDate, string EndDate, long IdStatus) { DateTime?EndDateDT = null; if (!string.IsNullOrEmpty(EndDate) && (EndDate.Length > 0)) { EndDateDT = DateTime.Parse(EndDate); } 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 = DateTime.Parse(StartDate); project.EndDate = EndDateDT; project.IdStatus = IdStatus; objCtx.SaveChanges(); } return(true); }
public static string ChangePasswordJSON(int Id, string OldPassword, string NewPassword) { AjaxReturnMessage res = new AjaxReturnMessage(); using (var objCtx = new PWMEntities()) { var resource = objCtx.Resource.SingleOrDefault(x => x.Id == Id); if (resource.Password != OldPassword) { res.Result = false; res.Message = "A senha actual está incorrecta."; } else { resource.Password = NewPassword; objCtx.SaveChanges(); res.Result = true; } } string json = JsonConvert.SerializeObject(res); return(json); }