/// <summary> /// Change password method which will interact with database and change the password /// </summary> /// <param name="changePassword">You need to pass ChangePassword type object to process the request</param> /// <returns></returns> public MDTTransactionInfo ChangePassword(ChangePassword changePassword) { MDTTransactionInfo mdt = null; try { List <SqlParameter> prm = new List <SqlParameter>(); //SqlParameter email = new SqlParameter("@email", changePassword.Email); //prm.Add(email); //SqlParameter oldPwd = new SqlParameter("@oldPwd", changePassword.OldPassword); //prm.Add(oldPwd); //SqlParameter NewPwd = new SqlParameter("@newPwd", changePassword.NewPassword); //prm.Add(NewPwd); //SqlParameter status = new SqlParameter("@Status", 0); //status.Direction = ParameterDirection.Output; //prm.Add(status); prm = DatabaseSettings.BindParamers(APIHelper.updatePasswordParameters, changePassword.Email + "~||~" + changePassword.OldPassword + "~||~" + changePassword.NewPassword); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.updatePassword, out StatusValue, prm); mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; } return(mdt); }
/// <summary> /// It will return mdt object with fail/pass based on Status /// </summary> /// <param name="obj"></param> /// <param name="Status"></param> /// <param name="message"></param> /// <param name="dt"></param> /// <returns></returns> public static MDTTransactionInfo GetTransObject(object obj, int Status, string message, DataSet ds = null) { MDTTransactionInfo mdt = new MDTTransactionInfo(); if (Status == 1) { mdt.transactionObject = obj; mdt.status = HttpStatusCode.OK; mdt.msgCode = MessageCode.Success; mdt.message = message; } else if (Status == 5 || Status == 6) { ErrorInfoFromSQL eInfo = null; foreach (DataTable dt in ds.Tables) { if (dt.Rows.Count > 0) { eInfo = new ErrorInfoFromSQL(); eInfo = GetError(dt); mdt.status = HttpStatusCode.BadRequest; mdt.transactionObject = eInfo; mdt.msgCode = (eInfo.Status == 1) ? MessageCode.Success : (eInfo.Status == 6) ? MessageCode.TechnicalError : MessageCode.Failed; mdt.message = eInfo.ErrorMessage; mdt.LineNumber = eInfo.ErrorLineNo; mdt.ProcedureName = eInfo.Procedure; } } } return(mdt); }
//[Route("login", Name = "Login")] public async Task <IHttpActionResult> Login(UserLogin userLogin) { MDTTransactionInfo transactionInfo = null; Logger Log = new Logger(); transactionInfo = await Task.Run(() => { try { if (userLogin == null) { Log.WriteErrorLog("userLogin object have no value or null"); } return(_iUserLogin.Login(userLogin)); } catch (Exception ex) { Log.WriteErrorLog(ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine); Log.WriteErrorLog(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); return(new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }); } }); return(Ok(transactionInfo)); }
public IHttpActionResult GetPackageSystem(int PackageID) { MDTTransactionInfo tInfo = null; try { tInfo = (PackageID == 0) ? new MDTTransactionInfo { msgCode = MessageCode.Failed, message = "Invalid Data", status = HttpStatusCode.BadRequest } : _service.GetPackageSystemDetails(PackageID); } catch (Exception ex) { Logger Log = new Logger(); Log.WriteErrorLog(ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine); Log.WriteErrorLog(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); tInfo = new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }; } return(Ok(tInfo)); }
/// <summary> /// It will return mdt object with fail/pass based on Status /// </summary> /// <param name="obj"></param> /// <param name="Status"></param> /// <param name="message"></param> /// <param name="dt"></param> /// <returns></returns> public static MDTTransactionInfo GetTransObject(object obj, int Status, string message, DataTable dt = null) { MDTTransactionInfo mdt = new MDTTransactionInfo(); if (Status == 1) { mdt.transactionObject = obj; mdt.status = HttpStatusCode.OK; mdt.msgCode = MessageCode.Success; mdt.message = message; } else if (APIHelper.StatusValue == 5) { ErrorInfoFromSQL eInfo = null; if (dt.Rows.Count > 0) { eInfo = new ErrorInfoFromSQL(); eInfo = DatabaseSettings.GetError(dt); mdt.status = HttpStatusCode.BadRequest; mdt.transactionObject = eInfo; mdt.msgCode = (eInfo.Status == 1) ? MessageCode.Success : MessageCode.Failed; mdt.message = eInfo.ErrorMessage; mdt.LineNumber = eInfo.ErrorLineNo; mdt.ProcedureName = eInfo.Procedure; } } return(mdt); }
public async Task <IHttpActionResult> ForgotPassword(ForgotPassword forgotPassword) { MDTTransactionInfo transactionInfo = null; Logger Log = new Logger(); transactionInfo = await Task.Run(() => { try { return(_iforgotPassword.ForgotPassword(forgotPassword)); } catch (Exception ex) { Log.WriteErrorLog(ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine); Log.WriteErrorLog(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); return(new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }); } }); return(Ok(transactionInfo)); }
public MDTTransactionInfo UploadProfilePic(List <string> files) { HttpResponseMessage result = null; MDTTransactionInfo mdt = new MDTTransactionInfo(); var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var docfiles = new List <string>(); foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var filePath = HttpContext.Current.Server.MapPath("~/" + postedFile.FileName); postedFile.SaveAs(filePath); docfiles.Add(filePath); } result = Request.CreateResponse(HttpStatusCode.Created, docfiles); } else { result = Request.CreateResponse(HttpStatusCode.BadRequest); } return(result); }
/// <summary> /// It will return equipment variants with their cost history based on Variant ID /// </summary> /// <param name="VariantID">Pass the variant ID for associated equipment</param> /// <returns></returns> public MDTTransactionInfo GetEquipmentVariants(int packageID, int systemID, int configurationID, int variantID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); try { IEnumerable <EquipmentVariants> equipmentVariants = null; List <SqlParameter> prm = new List <SqlParameter>(); prm = DatabaseSettings.BindParamers(APIHelper.getEquipmentVariantsParameters, packageID.ToString() + "~||~" + systemID.ToString() + "~||~" + configurationID.ToString() + "~||~" + variantID.ToString()); int statusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getEquipmentVariants, out statusValue, prm); DataTable dt; if (statusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { equipmentVariants = from d in dt.AsEnumerable() select new EquipmentVariants { SELECT = Convert.ToBoolean(d.Field <int>("SELECT")), PACKAGE_ID = d.Field <int>("PACKAGE_ID"), SYSTEM_ID = d.Field <int>("SYSTEM_ID"), EQUIPMENT_ID = d.Field <int>("EQUIPMENT_ID"), SUPPLIER_ID = d.Field <int>("SUPPLIER_ID"), CONFIGURATION_ID = d.Field <int>("CONFIGURATION_ID"), UPDT_USER_ID = d.Field <int>("UPDT_USER_ID"), IS_MANDATORY = d.Field <bool>("IS_MANDATORY"), EQUIPMENT_NAME = d.Field <string>("EQUIPMENT_NAME"), SUPPLIER_NAME = d.Field <string>("SUPPLIER_NAME"), EQUIPMENT_COST = d.Field <double>("EQUIPMENT_COST"), EQPMNT_VARIANT_ID = d.Field <int>("EQPMNT_VARIANT_ID"), COMMENTS = d.Field <string>("COMMENTS"), EQUIPMENT_DESC = d.Field <string>("EQUIPMENT_DESC"), EQUIPMENT_TYPE = d.Field <string>("EQUIPMENT_TYPE"), Documents = GetEquipmentDocuments(d.Field <int>("EQUIPMENT_ID")).transactionObject as IEnumerable <EquipmentDocuments>, SAPLinks = GetEquipmentSAPLinks(d.Field <int>("EQUIPMENT_ID")).transactionObject as IEnumerable <EquipmentSAPLink>, Suppliers = Suppliers = GetSuppliers(d.Field <int>("SYSTEM_ID"), d.Field <int>("EQUIPMENT_ID"), d.Field <int>("CONFIGURATION_ID"), d.Field <string>("EQUIPMENT_TYPE")) //(d.Field<int>("SUPPLIER_ID")!=0)?Suppliers:null }; mdt = DatabaseSettings.GetTransObject(equipmentVariants, statusValue, "System equipment variants fetched successfully", ds); } else { mdt.msgCode = MessageCode.Failed; mdt.status = HttpStatusCode.NoContent; mdt.message = "No record found"; } } } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; // Need to log error in logger from ex } return(mdt); }
/// <summary> /// It will auto generate new random password and send to user on his email. /// </summary> /// <param name="forgotPassword"></param> /// <returns></returns> public MDTTransactionInfo ForgotPassword(ForgotPassword forgotPassword) { MDTTransactionInfo mdt = new MDTTransactionInfo(); ErrorInfoFromSQL eInfo = null; try { List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter email = new SqlParameter("@email", forgotPassword.Email); prm.Add(email); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.forgotPassword, out StatusValue, prm); DataTable dt = ds.Tables[0]; if (StatusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { SendMailRequest sendMailRequest = new SendMailRequest(); sendMailRequest.recipient = dt.Rows[0]["Email"].ToString(); sendMailRequest.subject = "MDT Password Reset"; sendMailRequest.body = "Dear User," + Environment.NewLine + "Your password has been reset successfully. please login with new password given below " + Environment.NewLine + "New Password : "******"New Password"].ToString(); IMessager messager = new Email(); var Notification = new Notification(messager); if (Notification.DoNotify(sendMailRequest)) { mdt.status = HttpStatusCode.OK; mdt.msgCode = MessageCode.Success; mdt.message = "Password has been reset and sent to your registered email."; } else { mdt.status = HttpStatusCode.BadGateway; mdt.msgCode = MessageCode.Failed; mdt.message = "Password has been reset but unable to send an email due some technical issue, please contact to administrator"; } } } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; } return(mdt); }
public IHttpActionResult UploadPic(int UserID) { MDTTransactionInfo tInfo = null; try { string ProfilePicPath; if (UserID == 0) { tInfo = new MDTTransactionInfo { msgCode = MessageCode.Failed, message = "Invalid Data", status = HttpStatusCode.BadRequest } } ; else { var httpRequest = HttpContext.Current.Request; string Status = string.Empty; if (httpRequest.Files.Count > 0) { var docfiles = new List <string>(); foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; string filename = "UserPic_" + UserID.ToString() + Path.GetExtension(postedFile.FileName).ToLower().Trim(); var filePath = HttpContext.Current.Server.MapPath("~/Uploads/ProfilePics/" + filename); postedFile.SaveAs(filePath); docfiles.Add(filePath); ProfilePicPath = "Uploads/ProfilePics/" + filename; tInfo = _service.UploadProfilePic(UserID, ProfilePicPath); } } else { tInfo = new MDTTransactionInfo { msgCode = MessageCode.Success, message = "File uploading failed.", status = HttpStatusCode.OK }; } } } catch (Exception ex) { Logger Log = new Logger(); Log.WriteErrorLog(ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine); Log.WriteErrorLog(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); tInfo = new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }; } return(null); }
/// <summary> /// This is login method and it will connect to DB and check if user is exists or not. If user exists then it will display the user detail /// </summary> /// <param name="userLogin"></param> /// <returns></returns> public MDTTransactionInfo Login(UserLogin userLogin) { MDTTransactionInfo mdt = new MDTTransactionInfo(); UserLoginDetails loginDetails = null; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter email = new SqlParameter("@email", userLogin.UserName); prm.Add(email); SqlParameter pwd = new SqlParameter("@pwd", userLogin.Password); prm.Add(pwd); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); DataTable dt = DatabaseSettings.GetDataSet("sp_LoginUser", out APIHelper.StatusValue, prm).Tables[0]; if (APIHelper.StatusValue == 1) { if (dt.Rows.Count > 0) { loginDetails = new UserLoginDetails(); loginDetails.USER_ID = Convert.ToInt32(dt.Rows[0]["USER_ID"]); loginDetails.FIRST_NAME = dt.Rows[0]["FIRST_NAME"].ToString(); loginDetails.LAST_NAME = dt.Rows[0]["LAST_NAME"].ToString(); loginDetails.EMAIL_ADDRESS = dt.Rows[0]["EMAIL_ADDRESS"].ToString(); loginDetails.FORCE_PWD_CHNG = Convert.ToBoolean(dt.Rows[0]["FORCE_PWD_CHNG"]); loginDetails.PHOTO = dt.Rows[0]["PHOTO"].ToString(); loginDetails.ROLE_NAME = dt.Rows[0]["ROLE_NAME"].ToString(); loginDetails.ROLE_ID = Convert.ToInt32(dt.Rows[0]["ROLE_ID"]); } mdt.status = HttpStatusCode.OK; mdt.transactionObject = loginDetails; mdt.msgCode = MessageCode.Success; mdt.message = "Login Successfully"; } else if (APIHelper.StatusValue == 5) { ErrorInfoFromSQL eInfo = null; if (dt.Rows.Count > 0) { eInfo = new ErrorInfoFromSQL(); eInfo = DatabaseSettings.GetError(dt); mdt.status = HttpStatusCode.BadRequest; mdt.transactionObject = eInfo; mdt.msgCode = (eInfo.Status == 1) ? MessageCode.Success : MessageCode.Failed; mdt.message = eInfo.ErrorMessage; mdt.LineNumber = eInfo.ErrorLineNo; mdt.ProcedureName = eInfo.Procedure; } } return(mdt); }
private MDTTransactionInfo GetBasicInputOptions(int basicInputID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); try { IEnumerable <BasicInputOptions> basicInputOptions = null; List <SqlParameter> prm = new List <SqlParameter>(); //SqlParameter Basic_Input_ID = new SqlParameter("@BASIC_INPUT_ID", basicInputID); //prm.Add(Basic_Input_ID); //SqlParameter status = new SqlParameter("@Status", 0); //status.Direction = ParameterDirection.Output; //prm.Add(status); prm = DatabaseSettings.BindParamers(APIHelper.getBasicInputDetailsParameters, basicInputID.ToString()); int statusValue = 0; DataSet ds = DatabaseSettings.GetDataSet("sp_GetBasicInputDetails", out statusValue, prm); DataTable dt; if (statusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { basicInputOptions = from d in dt.AsEnumerable() select new BasicInputOptions { BASIC_INPUT_OPTN_ID = d.Field <int>("BASIC_INPUT_OPTN_ID"), INPUT_OPT_NAME = d.Field <string>("INPUT_OPT_NAME"), BASIC_INPUT_ID = d.Field <int>("BASIC_INPUT_ID"), //CONFIGURATION_ID = d.Field<int>("CONFIGURATION_ID"), //CONFIG_INPUT_OPT_ID = d.Field<int>("CONFIG_INPUT_OPT_ID"), //UPDT_USER_ID = d.Field<int>("UPDT_USER_ID") }; } mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; mdt.message = "Record found"; mdt.transactionObject = basicInputOptions; } else if (statusValue == 5 || statusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, statusValue, "", ds); } } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; } return(mdt); }
/// <summary> /// It will auto generate new random password and send to user on his email. /// </summary> /// <param name="forgotPassword"></param> /// <returns></returns> public MDTTransactionInfo ForgotPassword(ForgotPassword forgotPassword) { MDTTransactionInfo mdt = new MDTTransactionInfo();; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter email = new SqlParameter("@email", forgotPassword.Email); prm.Add(email); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet("sp_UpdatePassword", out StatusValue, prm); DataTable dt = ds.Tables[0]; ErrorInfoFromSQL eInfo = null; if (StatusValue == 1) { mdt.status = HttpStatusCode.OK; } else if (StatusValue == 5) { mdt.status = HttpStatusCode.BadRequest; } if (dt.Rows.Count == 1) { eInfo = DatabaseSettings.GetError(dt); mdt.transactionObject = eInfo; mdt.msgCode = (eInfo.Status == 1) ? MessageCode.Success : MessageCode.Failed; mdt.message = eInfo.ErrorMessage; mdt.LineNumber = eInfo.ErrorLineNo; mdt.ProcedureName = eInfo.Procedure; } // If above call success then sending an email to user with latest password. if (eInfo.Status == 1) { dt = ds.Tables[1]; if (dt.Rows.Count > 0) { SendMailRequest sendMailRequest = new SendMailRequest(); sendMailRequest.recipient = dt.Rows[0]["Email"].ToString(); sendMailRequest.subject = "MDT Password Reset"; sendMailRequest.body = "Dear User," + Environment.NewLine + "Your password has been reset successfully. please login with new password given below " + Environment.NewLine + "New Password : "******"New Password"].ToString(); IMessager messager = new Email(); var Notification = new Notification(messager); mdt.message = Notification.DoNotify(sendMailRequest); } } return(mdt); }
/// <summary> /// It will return the Sub System details in landing page for sales based on Package ID /// </summary> /// <param name="PackageID"></param> /// <returns></returns> public MDTTransactionInfo GetPackageSystemDetails(int PackageID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); IEnumerable <PackageSystem> PackageSystems = null; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter package_Id = new SqlParameter("@PackageID", PackageID); prm.Add(package_Id); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getPackageSystemDetails, out StatusValue, prm); DataTable dt; if (StatusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { PackageSystems = from d in dt.AsEnumerable() select new PackageSystem { PACKAGE_ID = d.Field <int>("PACKAGE_ID"), SYSTEM_ID = d.Field <int>("SYSTEM_ID"), SYSTEM_VARIANT_ID = d.Field <int>("SYSTEM_VARIANT_ID"), DEPENDENT_ID = d.Field <int>("DEPENDENT_ID"), SELECT = Convert.ToBoolean(d.Field <int>("SELECT")), TYPE = d.Field <bool>("TYPE"), COST_TYPE = Convert.ToBoolean(d.Field <int>("COST_TYPE")), SYSTEM_IMAGE = d.Field <string>("SYSTEM_IMAGE"), SYSTEM_NAME = d.Field <string>("SYSTEM_NAME"), EQUIPMENT_COST = d.Field <double>("EQUIPMENT_COST"), ELECTRICAL_COST = d.Field <double>("ELECTRICAL_COST"), MECHANICAL_COST = d.Field <double>("MECHANICAL_COST"), COMMENTS = d.Field <string>("COMMENTS"), REMARKS = d.Field <string>("REMARKS"), SystemVariants = GetSystemVariants(d.Field <int>("SYSTEM_VARIANT_ID")).transactionObject as IEnumerable <SystemVariants> }; } mdt = DatabaseSettings.GetTransObject(PackageSystems, StatusValue, "Package System Details Fetched Successfully", ds); } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } return(mdt); }
private MDTTransactionInfo GetSystemVariants(int VariantID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); IEnumerable <SystemVariants> systemVariants = null; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter System_Variant_ID = new SqlParameter("@System_Variant_ID", VariantID); prm.Add(System_Variant_ID); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getSystemVariants, out StatusValue, prm); DataTable dt; if (StatusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { systemVariants = from d in dt.AsEnumerable() select new SystemVariants { PACKAGE_ID = d.Field <int>("PACKAGE_ID"), SYSTEM_ID = d.Field <int>("SYSTEM_ID"), SYSTEM_VARIANT_ID = d.Field <int>("SYSTEM_VARIANT_ID"), DEPENDENT_ID = d.Field <int>("DEPENDENT_ID"), SELECT = Convert.ToBoolean(d.Field <int>("SELECT")), TYPE = d.Field <bool>("TYPE"), COST_TYPE = Convert.ToBoolean(d.Field <int>("COST_TYPE")), SYSTEM_IMAGE = d.Field <string>("SYSTEM_IMAGE"), SYSTEM_NAME = d.Field <string>("SYSTEM_NAME"), EQUIPMENT_COST = d.Field <double>("EQUIPMENT_COST"), ELECTRICAL_COST = d.Field <double>("ELECTRICAL_COST"), MECHANICAL_COST = d.Field <double>("MECHANICAL_COST"), COMMENTS = d.Field <string>("COMMENTS"), REMARKS = d.Field <string>("REMARKS") }; } mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; mdt.message = "Record found"; mdt.transactionObject = systemVariants; } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } return(mdt); }
/// <summary> /// This will return list of Basic input options available in database /// </summary> /// <returns></returns> public MDTTransactionInfo GetBasicInputs() { MDTTransactionInfo mdt = new MDTTransactionInfo(); IEnumerable <BasicInput> basicInputs = null; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getBasicInput, out StatusValue, prm); DataTable dt; if (StatusValue == 1) { mdt = new MDTTransactionInfo(); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { basicInputs = from d in dt.AsEnumerable() select new BasicInput { BASIC_INPUT_ID = d.Field <int>("BASIC_INPUT_ID"), BASIC_INPUT_NAME = d.Field <string>("BASIC_INPUT_NAME"), BasicInputOptions = GetBasicInputOptions(d.Field <int>("BASIC_INPUT_ID")).transactionObject as IEnumerable <BasicInputOptions> }; } if (basicInputs != null) { mdt.transactionObject = basicInputs; mdt.status = HttpStatusCode.OK; mdt.msgCode = MessageCode.Success; mdt.message = "Fetched basic input detail successfully"; } else { mdt.transactionObject = null; mdt.status = HttpStatusCode.NotFound; mdt.msgCode = MessageCode.Failed; mdt.message = "No record found"; } } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } return(mdt); }
/// <summary> /// This will return the list side menu from Solution to Configuration /// </summary> /// <returns></returns> public MDTTransactionInfo GetSideMenu(int UserID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); try { IEnumerable <SolutionList> solutionLists = null; //List<SqlParameter> prm = new List<SqlParameter>(); //SqlParameter Status = new SqlParameter("@Status", 0); //Status.Direction = ParameterDirection.Output; //prm.Add(Status); List <SqlParameter> prm = DatabaseSettings.BindParamers(); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getSolutions, out StatusValue, prm); DataTable dt; if (StatusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { solutionLists = from d in dt.AsEnumerable() select new SolutionList { SOLUTION_ID = d.Field <int>("SOLUTION_ID"), SOLUTION_NAME = d.Field <string>("SOLUTION_NAME"), Packages = GetPackageList(d.Field <int>("SOLUTION_ID"), UserID).transactionObject as IEnumerable <PackageList> }; } //mdt = DatabaseSettings.GetTransObject(solutionLists, StatusValue, "Record Found", ds); mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; mdt.message = "Record found"; mdt.transactionObject = solutionLists; } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; } return(mdt); }
public IHttpActionResult Get() { MDTTransactionInfo tInfo = null; try { tInfo = _service.GetBasicInputs(); } catch (Exception ex) { tInfo = new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }; } return(Ok(tInfo)); }
/// <summary> /// It will return respective equipment SAP links to navigate SAP /// </summary> /// <param name="EquipmentID"></param> /// <returns></returns> public MDTTransactionInfo GetEquipmentSAPLinks(int equipmentID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); try { IEnumerable <EquipmentSAPLink> equipmentSAPLinks = null; List <SqlParameter> prm = new List <SqlParameter>(); prm = DatabaseSettings.BindParamers(APIHelper.getEquipmentSAPLinksParameters, equipmentID.ToString()); int statusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getEquipmentSAPLinks, out statusValue, prm); DataTable dt; if (statusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { equipmentSAPLinks = from d in dt.AsEnumerable() select new EquipmentSAPLink { SAP_LINK_ID = d.Field <int>("SAP_LINK_ID"), EQUIPMENT_ID = d.Field <int>("EQUIPMENT_ID"), NAME = d.Field <string>("NAME"), DESCRIPTION = d.Field <string>("DESCRIPTION"), SAP_LINK_URL = d.Field <string>("SAP_LINK_URL"), }; mdt = DatabaseSettings.GetTransObject(equipmentSAPLinks, statusValue, "System equipment SAP links fetched successfully", ds); } else { mdt.msgCode = MessageCode.Failed; mdt.status = HttpStatusCode.NoContent; mdt.message = "No record found"; } } } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; // Need to log error in logger from ex } return(mdt); }
/// <summary> /// It return all package list for respective Solution /// </summary> /// <param name="SolutionID"></param> /// <param name="UserID"></param> /// <returns></returns> private MDTTransactionInfo GetPackageList(int solutionID, int userID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); try { IEnumerable <PackageList> packageLists = null; List <SqlParameter> prm = DatabaseSettings.BindParamers(APIHelper.getPackageListParameters, solutionID.ToString()); int statusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getPackageList, out statusValue, prm); DataTable dt; if (statusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { packageLists = from d in dt.AsEnumerable() select new PackageList { PACKAGE_ID = d.Field <int>("PACKAGE_ID"), PACKAGE_NAME = d.Field <string>("PACKAGE_NAME"), SOLUTION_ID = d.Field <int>("SOLUTION_ID"), Configurations = GetConfigurationList(userID, d.Field <int>("PACKAGE_ID")).transactionObject as IEnumerable <ConfigurationList> }; } mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; mdt.message = "Record found"; mdt.transactionObject = packageLists; } else if (statusValue == 5 || statusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, statusValue, "", ds); } } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; } return(mdt); }
/// <summary> /// It will return Top 3 configurations for respective package and User /// </summary> /// <param name="UserID"></param> /// <param name="PackageID"></param> /// <returns></returns> private MDTTransactionInfo GetConfigurationList(int UserID, int PackageID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); IEnumerable <ConfigurationList> configLists = null; //List<SqlParameter> prm = new List<SqlParameter>(); //SqlParameter userID = new SqlParameter("@UserID", UserID); //prm.Add(userID); //SqlParameter packageID = new SqlParameter("@PackageID", PackageID); //prm.Add(packageID); //SqlParameter NoofConfiguration = new SqlParameter("@NoofConfiguration", 3); //prm.Add(NoofConfiguration); //SqlParameter Status = new SqlParameter("@Status", 0); //Status.Direction = ParameterDirection.Output; //prm.Add(Status); List <SqlParameter> prm = DatabaseSettings.BindParamers(APIHelper.getLatestConfigurationsParameters, UserID.ToString() + "," + PackageID.ToString() + ",3"); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getLatestConfigurations, out StatusValue, prm); DataTable dt; if (StatusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { configLists = from d in dt.AsEnumerable() select new ConfigurationList { CONFIGURATION_ID = d.Field <int>("CONFIGURATION_ID"), CONFIGURATION_NAME = d.Field <string>("CONFIGURATION_NAME"), PACKAGE_ID = d.Field <int>("PACKAGE_ID") }; } mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; mdt.message = "Record found"; mdt.transactionObject = configLists; } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } return(mdt); }
/// <summary> /// Change password method which will interact with database and change the password /// </summary> /// <param name="changePassword">You need to pass ChangePassword type object to process the request</param> /// <returns></returns> public MDTTransactionInfo ChangePassword(ChangePassword changePassword) { MDTTransactionInfo mdt = null; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter email = new SqlParameter("@email", changePassword.Email); prm.Add(email); SqlParameter oldPwd = new SqlParameter("@oldPwd", changePassword.OldPassword); prm.Add(oldPwd); SqlParameter NewPwd = new SqlParameter("@newPwd", changePassword.NewPassword); prm.Add(NewPwd); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.UpdatePassword, out StatusValue, prm); mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); //if (StatusValue == 1) //{ // mdt.status = HttpStatusCode.OK; //} //else if (StatusValue == 5 || StatusValue == 6) //{ // mdt.status = HttpStatusCode.BadRequest; //} //if (dt.Rows.Count == 1) //{ // ErrorInfoFromSQL eInfo = DatabaseSettings.GetError(dt); // mdt.transactionObject = eInfo; // mdt.message = eInfo.ErrorMessage; // mdt.msgCode = (eInfo.Status == 1) ? MessageCode.Success : (eInfo.Status == 6) ? MessageCode.TechnicalError : MessageCode.Failed; // mdt.LineNumber = eInfo.ErrorLineNo; // mdt.ProcedureName = eInfo.Procedure; //} return(mdt); }
/// <summary> /// This will return the list side menu from Solution to Configuration /// </summary> /// <returns></returns> public MDTTransactionInfo GetSideMenu(int UserID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); IEnumerable <SolutionList> solutionLists = null; SolutionList solutionList = null; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter Status = new SqlParameter("@Status", 0); Status.Direction = ParameterDirection.Output; prm.Add(Status); int StatusValue = 0; DataTable dt = DatabaseSettings.GetDataSet("sp_GetSolutions", out StatusValue, prm).Tables[0]; if (StatusValue == 1) { if (dt.Rows.Count > 0) { solutionLists = from d in dt.AsEnumerable() select new SolutionList { SOLUTION_ID = d.Field <int>("SOLUTION_ID"), SOLUTION_NAME = d.Field <string>("SOLUTION_NAME"), Packages = GetPackageList(d.Field <int>("SOLUTION_ID"), UserID) }; //solutionLists = new List<SolutionList>(); //foreach (DataRow row in dt.Rows) //{ // solutionList = new SolutionList(); // solutionList.SOLUTION_ID = Convert.ToInt32(row["SOLUTION_ID"]); // solutionList.SOLUTION_NAME = row["SOLUTION_NAME"].ToString(); // if (Convert.ToInt32(row["SOLUTION_ID"]) > 0) // { // solutionList.Packages = GetPackageList(Convert.ToInt32(row["SOLUTION_ID"]), UserID); // } // solutionLists.Add(solutionList); //} } } mdt = DatabaseSettings.GetTransObject(solutionLists, StatusValue, "Record Found", dt); return(mdt); }
/// <summary> /// Change password method which will interact with database and change the password /// </summary> /// <param name="changePassword">You need to pass ChangePassword type object to process the request</param> /// <returns></returns> public MDTTransactionInfo ChangePassword(ChangePassword changePassword) { MDTTransactionInfo mdt = new MDTTransactionInfo(); List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter email = new SqlParameter("@email", changePassword.Email); prm.Add(email); SqlParameter oldPwd = new SqlParameter("@oldPwd", changePassword.OldPassword); prm.Add(oldPwd); SqlParameter NewPwd = new SqlParameter("@newPwd", changePassword.NewPassword); prm.Add(NewPwd); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); DataTable dt = DatabaseSettings.GetDataSet("sp_UpdatePassword", out APIHelper.StatusValue, prm).Tables[0]; if (APIHelper.StatusValue == 1) { mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; } else if (APIHelper.StatusValue == 5) { mdt.status = HttpStatusCode.BadRequest; mdt.msgCode = MessageCode.Failed; } if (dt.Rows.Count == 1) { ErrorInfoFromSQL eInfo = DatabaseSettings.GetError(dt); mdt.transactionObject = eInfo; mdt.message = eInfo.ErrorMessage; mdt.LineNumber = eInfo.ErrorLineNo; mdt.ProcedureName = eInfo.Procedure; } return(mdt); }
/// <summary> /// It return all package list for respective Solution /// </summary> /// <param name="SolutionID"></param> /// <param name="UserID"></param> /// <returns></returns> private MDTTransactionInfo GetPackageList(int SolutionID, int UserID) { IEnumerable <PackageList> packageLists = null; //PackageList packageList = null; MDTTransactionInfo mdt = new MDTTransactionInfo(); //List<SqlParameter> prm = new List<SqlParameter>(); //SqlParameter Solution_ID = new SqlParameter("@SolutionID", SolutionID); //prm.Add(Solution_ID); //SqlParameter Status = new SqlParameter("@Status", 0); //Status.Direction = ParameterDirection.Output; //prm.Add(Status); List <SqlParameter> prm = DatabaseSettings.BindParamers(APIHelper.getPackageListParameters, SolutionID.ToString()); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getPackageList, out StatusValue, prm); DataTable dt; if (StatusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { packageLists = from d in dt.AsEnumerable() select new PackageList { PACKAGE_ID = d.Field <int>("PACKAGE_ID"), PACKAGE_NAME = d.Field <string>("PACKAGE_NAME"), SOLUTION_ID = d.Field <int>("SOLUTION_ID"), Configurations = GetConfigurationList(UserID, d.Field <int>("PACKAGE_ID")).transactionObject as IEnumerable <ConfigurationList> }; } mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; mdt.message = "Record found"; mdt.transactionObject = packageLists; } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } return(mdt); }
/// <summary> /// This will update the user profile pic path into DB after upload. /// </summary> /// <param name="UserID"></param> /// <param name="filePath"></param> /// <returns></returns> public MDTTransactionInfo UploadProfilePic(int UserID, string filePath) { MDTTransactionInfo mdt = null; List <SqlParameter> prm = new List <SqlParameter>(); SqlParameter userid = new SqlParameter("@UserID", UserID); prm.Add(userid); SqlParameter filepath = new SqlParameter("@ProfilePic", filePath); prm.Add(filepath); SqlParameter status = new SqlParameter("@Status", 0); status.Direction = ParameterDirection.Output; prm.Add(status); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.UploadProfilePic, out StatusValue, prm); UploadProfilePics uploadProfilePics = new UploadProfilePics(); if (StatusValue == 1) { mdt = new MDTTransactionInfo(); uploadProfilePics.ProfilePicPath = filePath; mdt.transactionObject = uploadProfilePics; mdt.status = HttpStatusCode.OK; mdt.msgCode = MessageCode.Success; mdt.message = "File uploaded successfully"; } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } //if (dt.Rows.Count == 1) //{ // ErrorInfoFromSQL eInfo = DatabaseSettings.GetError(dt); // mdt.transactionObject = eInfo; // mdt.message = eInfo.ErrorMessage; // mdt.msgCode = (eInfo.Status == 1) ? MessageCode.Success : (eInfo.Status == 6) ? MessageCode.TechnicalError : MessageCode.Failed; // mdt.LineNumber = eInfo.ErrorLineNo; // mdt.ProcedureName = eInfo.Procedure; //} return(mdt); }
/// <summary> /// It will return Top 3 configurations for respective package and User /// </summary> /// <param name="UserID"></param> /// <param name="PackageID"></param> /// <returns></returns> private MDTTransactionInfo GetConfigurationList(int userID, int packageID) { MDTTransactionInfo mdt = new MDTTransactionInfo(); try { IEnumerable <ConfigurationList> configLists = null; List <SqlParameter> prm = DatabaseSettings.BindParamers(APIHelper.getLatestConfigurationsParameters, userID.ToString() + "~||~" + packageID.ToString() + "~||~" + ConfigurationManager.AppSettings["NumberOfConfiguration"].ToString()); int StatusValue = 0; DataSet ds = DatabaseSettings.GetDataSet(APIHelper.getLatestConfigurations, out StatusValue, prm); DataTable dt; if (StatusValue == 1) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { configLists = from d in dt.AsEnumerable() select new ConfigurationList { CONFIGURATION_ID = d.Field <int>("CONFIGURATION_ID"), CONFIGURATION_NAME = d.Field <string>("CONFIGURATION_NAME"), PACKAGE_ID = d.Field <int>("PACKAGE_ID") }; } mdt.msgCode = MessageCode.Success; mdt.status = HttpStatusCode.OK; mdt.message = "Record found"; mdt.transactionObject = configLists; } else if (StatusValue == 5 || StatusValue == 6) { mdt = DatabaseSettings.GetTransObject(null, StatusValue, "", ds); } } catch (Exception ex) { mdt.status = HttpStatusCode.ExpectationFailed; mdt.msgCode = MessageCode.TechnicalError; mdt.message = "Technical Error in the system, please contact to administrator"; } return(mdt); }
public IHttpActionResult GetSideMenu(int UserID) { MDTTransactionInfo tInfo = null; try { tInfo = (UserID == 0) ? new MDTTransactionInfo { msgCode = MessageCode.Failed, message = "Invalid Data", status = HttpStatusCode.BadRequest } : _service.GetSideMenu(UserID); } catch (Exception ex) { tInfo = new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }; } return(Ok(tInfo)); }
public IHttpActionResult GetEquipments(int PackageID, int SystemID, int ConfigurationID) { MDTTransactionInfo tInfo = null; try { tInfo = (PackageID == 0 || SystemID == 0) ? new MDTTransactionInfo { msgCode = MessageCode.Failed, message = "Invalid Data", status = HttpStatusCode.BadRequest } : _service.GetEquipmentsDetail(PackageID, SystemID, ConfigurationID); } catch (Exception ex) { tInfo = new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }; } return(Ok(tInfo)); }
public async Task <IHttpActionResult> ChangePassword(ChangePassword changePassword) { MDTTransactionInfo transactionInfo = null; transactionInfo = await Task.Run(() => { try { return(_service.ChangePassword(changePassword)); } catch (Exception ex) { return(new MDTTransactionInfo { msgCode = MessageCode.Failed, message = ex.Message, status = HttpStatusCode.InternalServerError }); } }); return(Ok(transactionInfo)); }