public AnswerResponseBE UpdateActivities(ActivitiesBE UPACTI) { AnswerResponseBE AR = new AnswerResponseBE(); EmploActiEntities BDEA = new EmploActiEntities(); try { Activities activities = new Activities(); activities = BDEA.Activities.Where(x => x.ActivitiesCode == UPACTI.ActivitiesCode).FirstOrDefault(); if (activities != null) { activities.NameActivities = UPACTI.NameActivities; BDEA.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha actualizado la actividad correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro no existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDEA.Dispose(); } return(AR); }
public AnswerResponseBE DeleteTimeActivity(int TIMEACTIVITECODE) { AnswerResponseBE AR = new AnswerResponseBE(); EmploActiEntities BDEA = new EmploActiEntities(); try { var idTimeacti = BDEA.TimeActivity.Where(x => x.CodeTimeActivity == TIMEACTIVITECODE).FirstOrDefault(); if (idTimeacti != null) { BDEA.TimeActivity.Remove(idTimeacti); BDEA.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se eliminó con éxito"; } else { AR.CodeError = 1; AR.DescriptionError = "El registro no existe"; } } catch (Exception EX) { AR.CodeError = 2; AR.DescriptionError = "Hubo un error"; } finally { BDEA.Dispose(); } return(AR); }
public AnswerResponseBE InsertTimeActivity(TimeActivityBE ITIMAC) { AnswerResponseBE AR = new AnswerResponseBE(); EmploActiEntities BDEA = new EmploActiEntities(); try { int CountTimeActi = 0; CountTimeActi = BDEA.TimeActivity.Where(x => x.CodeTimeActivity == ITIMAC.CodeTimeActivity).ToList().Count(); if (CountTimeActi == 0) { TimeActivity TIMACT = new TimeActivity(); TIMACT.ActivitiesCode = ITIMAC.ActivitiesCode; TIMACT.DateActivity = ITIMAC.DateActivity; TIMACT.Hours = ITIMAC.Hours; TIMACT.IdUser = ITIMAC.IdUser; BDEA.TimeActivity.Add(TIMACT); BDEA.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha insertado el tiempo / actividad correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro ya existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDEA.Dispose(); } return(AR); }
public AnswerResponseBE InsertUser(UserBE IUSER) { AnswerResponseBE AR = new AnswerResponseBE(); EmploActiEntities BDEA = new EmploActiEntities(); try { int CountUser = 0; CountUser = BDEA.User.Where(x => x.IdUser == IUSER.IdUser).ToList().Count(); if (CountUser == 0) { User US = new User(); US.NameUser = IUSER.NameUser; US.Password = IUSER.Password; BDEA.User.Add(US); BDEA.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha insertado el usuario correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro ya existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDEA.Dispose(); } return(AR); }
public AnswerResponseBE InsertActivities(ActivitiesBE IACT) { AnswerResponseBE AR = new AnswerResponseBE(); EmploActiEntities BDEA = new EmploActiEntities(); try { int CountActi = 0; CountActi = BDEA.Activities.Where(x => x.ActivitiesCode == IACT.ActivitiesCode).ToList().Count(); if (CountActi == 0) { Activities ACTIV = new Activities(); ACTIV.NameActivities = IACT.NameActivities; ACTIV.IdUser = IACT.IdUser; BDEA.Activities.Add(ACTIV); BDEA.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha insertado la actividad correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro ya existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDEA.Dispose(); } return(AR); }
public AnswerResponseBE UpdateTimeActivity(TimeActivityBE UPTIMEACT) { AnswerResponseBE AR = new AnswerResponseBE(); EmploActiEntities BDEA = new EmploActiEntities(); try { TimeActivity timeactivity = new TimeActivity(); timeactivity = BDEA.TimeActivity.Where(x => x.CodeTimeActivity == UPTIMEACT.CodeTimeActivity).FirstOrDefault(); if (timeactivity != null) { timeactivity.ActivitiesCode = UPTIMEACT.ActivitiesCode; timeactivity.DateActivity = UPTIMEACT.DateActivity; timeactivity.Hours = UPTIMEACT.Hours; BDEA.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha actualizado el tiempo / actividad correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro no existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDEA.Dispose(); } return(AR); }
public AnswerResponseBE UpdateUser(UserBE UPUSER) { AnswerResponseBE AR = new AnswerResponseBE(); EmploActiEntities BDEA = new EmploActiEntities(); try { User user = new User(); user = BDEA.User.Where(x => x.IdUser == UPUSER.IdUser).FirstOrDefault(); if (user != null) { user.NameUser = UPUSER.NameUser; user.Password = UPUSER.Password; BDEA.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha actualizado el usuario correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro no existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDEA.Dispose(); } return(AR); }