public ResultModel AddDealData(DealData data) { ResultModel rm = new ResultModel(); try { ExceptionHandle_ext eh = new Models.ExceptionHandle_ext(); eh.PoID = data.PoId; if (data.Type != 0) { eh.ProcessID = data.KeyId; } eh.Remark = data.Remark; eh.Status = 1; db.ExceptionHandle_ext.Add(eh); db.SaveChanges().ToString(); rm.IsSuccess = 1; } catch (Exception) { rm.ErrMessage = ""; } return(rm); }
private static void DeleteJobsByAssetId() { Console.Write("Please enter the asset id: "); string s = Console.ReadLine(); int assetId; if (!Int32.TryParse(s, out assetId)) { Console.WriteLine("Invalid asset id"); return; } using (APSEntities db = new APSEntities(DBHelper.GetConnectionString())) { var jobs = (from job in db.APSQueuedJob where job.AssetId == assetId select job); Console.WriteLine(string.Format("Found {0} jobs", jobs.Count())); foreach (APSQueuedJob job in jobs) { db.DeleteObject(job); Console.WriteLine("Deleted job with id: " + job.QueuedJobId); } db.SaveChanges(); Console.Write("All done"); } }
public UserModel CreateNewUser(UserModel model) { APSEntities dbContext = new APSEntities(); var objuser = new APS_USERS { USER_NAME = model.UserName, USER_PASSWORD = model.UserPassword, PWD_QUES_ID = model.SecretQuestionID, PWD_QUES_ANSWER = model.SecretQuestionAnswer, IS_DELETED = model.IsDeleted ? "0" : "1", LOGIN_FAIL_ATTEMPT = model.LoginFailAttemptCount, CREATED_BY = model.CreatedBy, CREATED_TIME = DateTime.Now, LAST_UPDATED_BY = model.LastUpdatedBy, LAST_UPDATED_TIME = DateTime.Now }; dbContext.APS_USERS.Add(objuser); dbContext.SaveChanges(); model.UserID = objuser.USER_ID; // create user dummy info var objUser_info = new APS_USER_INFO { USER_ID = model.UserID, USER_NAME = model.UserName, USER_FIRST_NAME = "DUMMY", USER_LAST_NAME = model.UserName, USER_MOBILE_NO = "86346745", USER_DATE_OF_BIRTH = DateTime.ParseExact("21-07-1980", "dd-mm-yyyy", CultureInfo.InvariantCulture), USER_EMAIL_ADDR = ConfigurationManager.AppSettings.Get("DummyEmailID").ToString(), CASE_OFFICER_NAME = "CO" + " " + model.UserName, CASE_OFFICER_EMAIL = ConfigurationManager.AppSettings.Get("DummyEmailID").ToString(), CASE_OFFICER_MOBILE_NO = "86346745", CREATED_BY = model.CreatedBy, CREATED_TIME = DateTime.Now, LAST_UPDATED_BY = model.LastUpdatedBy, LAST_UPDATED_TIME = DateTime.Now }; dbContext.APS_USER_INFO.Add(objUser_info); dbContext.SaveChanges(); return(model); }
public ForgetPasswordModel UpdateChangePasswordFailedCount(ForgetPasswordModel model) { APSEntities dbContext = new APSEntities(); var selectedEntity = dbContext.APS_USERS.FirstOrDefault(p => p.USER_NAME == model.UserName); selectedEntity.USER_NAME = model.UserName; selectedEntity.PWD_CHANGE_FAIL_ATTMPT = model.PasswordChangeFailAttempt; selectedEntity.LAST_UPDATED_BY = model.LastUpdatedBy; selectedEntity.LAST_UPDATED_TIME = DateTime.Now; dbContext.Entry(selectedEntity).State = EntityState.Modified; dbContext.SaveChanges(); return(model); }
public UserModel UpdateLoginFailedCount(UserModel model) { APSEntities dbContext = new APSEntities(); var selectedEntity = dbContext.APS_USERS.FirstOrDefault(p => p.USER_NAME == model.UserName); selectedEntity.USER_NAME = model.UserName; selectedEntity.LOGIN_FAIL_ATTEMPT = model.LoginFailAttemptCount; selectedEntity.LAST_UPDATED_BY = model.LastUpdatedBy; selectedEntity.LAST_UPDATED_TIME = DateTime.Now; dbContext.Entry(selectedEntity).State = EntityState.Modified; dbContext.SaveChanges(); return(selectedEntity.ToUserModel()); }
public void ActivityLogInsert(UserActivityLogModel activityModel) { APSEntities dbContext = new APSEntities(); var objUserActivity = new APS_USER_ACT_LOG { USER_NAME = activityModel.User_Name, USER_ACT_LOG = activityModel.User_Act_Log, CREATED_BY = activityModel.CreatedBy, CREATED_TIME = activityModel.CreatedTime }; dbContext.APS_USER_ACT_LOG.Add(objUserActivity); dbContext.SaveChanges(); }
public UserModel ChangeUserPassword(ChangePasswordModel model) { APSEntities dbContext = new APSEntities(); var selectedEntity = dbContext.APS_USERS.FirstOrDefault(p => p.USER_NAME == model.UserName); selectedEntity.USER_NAME = model.UserName; selectedEntity.USER_PASSWORD = model.UserPassword; selectedEntity.PWD_QUES_ID = model.PasswordQuestionID; selectedEntity.PWD_QUES_ANSWER = model.PasswordQuesAnswer; selectedEntity.LAST_UPDATED_BY = model.LastUpdatedBy; selectedEntity.LAST_UPDATED_TIME = DateTime.Now; dbContext.Entry(selectedEntity).State = EntityState.Modified; dbContext.SaveChanges(); UserModel userModel = ToUserModelFromChangePassword(model); return(userModel); }
public APS.BusinessEntity.Models.Appointment.AppointmentModel BookOrChangeAppointment(APS.BusinessEntity.Models.Appointment.AppointmentModel appModel) { try { UserInfoModel userInfo = new UserInfoModel(); userInfo.UserName = appModel.App_UserName; using (AuthenticationRepository authRepo = new AuthenticationRepository()) { userInfo = authRepo.GetUserInfoDetails(userInfo); } APS.BusinessEntity.Models.Appointment.AppointmentModel appointModel = new APS.BusinessEntity.Models.Appointment.AppointmentModel(); APSEntities dbContext = new APSEntities(); DateTime appDt; DateTime.TryParse(appModel.App_Date, out appDt); if (!appModel.IsAppointmentAvailable) { var objApp = new APS_APPOINTMENT { APP_DATE = appDt, APP_TIMESLOT_ID = appModel.App_TimeSlot_ID, APP_USERNAME = appModel.App_UserName, CREATED_BY = appModel.App_UserName, CREATED_ON = DateTime.Now, LAST_UPDATED_BY = appModel.App_UserName, LAST_UPDATED_ON = DateTime.Now, APP_STATUS = BusinessConstants.AppointmetStatus.Active, APP_CHANGE_CNT = 0 }; dbContext.APS_APPOINTMENT.Add(objApp); dbContext.SaveChanges(); appModel.App_ID = objApp.APP_ID; } else { var selectedEntity = dbContext.APS_APPOINTMENT.FirstOrDefault(p => p.APP_ID == appModel.App_ID); if (appModel.App_Change_Count <= 3) { selectedEntity.APP_CHANGE_CNT = appModel.App_Change_Count; selectedEntity.APP_TIMESLOT_ID = appModel.App_TimeSlot_ID; selectedEntity.LAST_UPDATED_BY = appModel.App_UserName; selectedEntity.LAST_UPDATED_ON = DateTime.Now; } else if (appModel.App_Change_Count > 3) { selectedEntity.APP_CHANGE_CNT = appModel.App_Change_Count; selectedEntity.LAST_UPDATED_BY = appModel.App_UserName; selectedEntity.LAST_UPDATED_ON = DateTime.Now; } dbContext.Entry(selectedEntity).State = EntityState.Modified; dbContext.SaveChanges(); } var appointments = dbContext.V_APPOINTMENT_DETAILS.Where(i => i.APP_USERNAME == appModel.App_UserName).FirstOrDefault(); if (appointments != null) { appointModel = appointments.ToAppointmentModel(); } appointModel.UserInfoDetails = userInfo; return(appointModel); } catch (Exception ex) { throw ex; } }