Ejemplo n.º 1
0
        private OuputModel DataAccessLogic(InputModel inputModel)
        {
            OuputModel     ouputModel     = null;
            DepatmentModel depatmentModel = null;

            using (SqlConnection sqlCon = new SqlConnection("Server=awsdatabase-1.cklc9dvnkg9x.ap-south-1.rds.amazonaws.com,1433;User Id=MainUser;pwd=V4wearefour;Database=Assignment"))
            {
                sqlCon.Open();

                using (SqlCommand commad = new SqlCommand("usp_getDept", sqlCon))
                {
                    commad.CommandType = System.Data.CommandType.StoredProcedure;


                    using (IDataReader reader = commad.ExecuteReader())
                    {
                        ouputModel = new OuputModel();
                        ouputModel.DepatmentList = new List <DepatmentModel>();
                        while (reader.Read())
                        {
                            depatmentModel = new DepatmentModel()
                            {
                                pkdeptid = reader.IsDBNull(reader.GetOrdinal("pkdeptid")) ? -1 : Convert.ToInt32(reader[reader.GetOrdinal("pkdeptid")]),
                                deptname = reader.IsDBNull(reader.GetOrdinal("deptname")) ? "" : reader[reader.GetOrdinal("deptname")].ToString(),
                                Isactive = reader.IsDBNull(reader.GetOrdinal("Isactive")) ? false : Convert.ToBoolean(reader[reader.GetOrdinal("Isactive")]),
                            };

                            ouputModel.DepatmentList.Add(depatmentModel);
                        }
                    }
                }
            }
            return(ouputModel);
        }
Ejemplo n.º 2
0
        private OuputModel DataAccessLogic(InputModel inputModel)
        {
            OuputModel ouputModel = null;

            using (SqlConnection sqlCon = new SqlConnection("Server=awsdatabase-1.cklc9dvnkg9x.ap-south-1.rds.amazonaws.com,1433;User Id=MainUser;pwd=V4wearefour;Database=Assignment"))
            {
                sqlCon.Open();

                using (SqlCommand commad = new SqlCommand("usp_Login", sqlCon))
                {
                    commad.CommandType = System.Data.CommandType.StoredProcedure;


                    commad.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar));
                    commad.Parameters["@Email"].Value = inputModel.Login.UserName.ToString();

                    commad.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar));
                    commad.Parameters["@Password"].Value = inputModel.Login.UserPassword.ToString();

                    using (IDataReader reader = commad.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            ouputModel = new OuputModel()
                            {
                                status = reader.IsDBNull(reader.GetOrdinal("Status")) ? false : Convert.ToBoolean(reader[reader.GetOrdinal("Status")]),
                            };
                        }
                    }

                    return(ouputModel);
                }
            }
        }
Ejemplo n.º 3
0
        public OuputModel Get(InputModel inputModel)
        {
            OuputModel ouputModel = null;

            ouputModel = DataAccessLogic(inputModel);

            return(ouputModel);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Sample_Main(InputModel inputModel)
        {
            OuputModel outputModel = null;

            try
            {
                if (inputModel == null)
                {
                    return(BadRequest(outputModel));
                }
                ActionFlow actionFlow = new ActionFlow();

                outputModel = await actionFlow.SampleActionFlow(inputModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Ok(outputModel));
        }
Ejemplo n.º 5
0
        private OuputModel DataAccessLogic(InputModel inputModel)
        {
            OuputModel    ouputModel   = null;
            EmployeeModel employeeList = null;

            using (SqlConnection sqlCon = new SqlConnection("Server=awsdatabase-1.cklc9dvnkg9x.ap-south-1.rds.amazonaws.com,1433;User Id=MainUser;pwd=V4wearefour;Database=Assignment"))
            {
                sqlCon.Open();

                using (SqlCommand commad = new SqlCommand("usp_getEmployee", sqlCon))
                {
                    commad.CommandType = System.Data.CommandType.StoredProcedure;

                    using (IDataReader reader = commad.ExecuteReader())
                    {
                        ouputModel = new OuputModel();
                        ouputModel.employeeList = new List <EmployeeModel>();
                        while (reader.Read())
                        {
                            employeeList = new EmployeeModel()
                            {
                                Pkempid  = reader.IsDBNull(reader.GetOrdinal("Pkempid")) ? -1 : Convert.ToInt32(reader[reader.GetOrdinal("Pkempid")]),
                                Empname  = reader.IsDBNull(reader.GetOrdinal("Empname")) ? "" : reader[reader.GetOrdinal("Empname")].ToString(),
                                Email    = reader.IsDBNull(reader.GetOrdinal("Email")) ? "" : reader[reader.GetOrdinal("Email")].ToString(),
                                Password = reader.IsDBNull(reader.GetOrdinal("Password")) ? "" : reader[reader.GetOrdinal("Password")].ToString(),
                                Salary   = reader.IsDBNull(reader.GetOrdinal("Salary")) ? -1 : Convert.ToDouble(reader[reader.GetOrdinal("Salary")]),
                                Isactive = reader.IsDBNull(reader.GetOrdinal("Isactive")) ? false : Convert.ToBoolean(reader[reader.GetOrdinal("Isactive")]),
                                Fkdeptid = reader.IsDBNull(reader.GetOrdinal("Fkdeptid")) ? -1 : Convert.ToInt32(reader[reader.GetOrdinal("Fkdeptid")]),
                                pkdeptid = reader.IsDBNull(reader.GetOrdinal("pkdeptid")) ? -1 : Convert.ToInt32(reader[reader.GetOrdinal("pkdeptid")]),
                                deptname = reader.IsDBNull(reader.GetOrdinal("deptname")) ? "" : reader[reader.GetOrdinal("deptname")].ToString(),
                            };

                            ouputModel.employeeList.Add(employeeList);
                        }
                    }
                }
            }
            return(ouputModel);
        }
Ejemplo n.º 6
0
        public async Task <OuputModel> SampleActionFlow(InputModel inputModel)
        {
            OuputModel outputModel;

            switch (inputModel.actionType)
            {
            case CommonModels.ActionType.AddEmployee:

                AddEmployee addEmployee = new AddEmployee();
                outputModel = addEmployee.Add(inputModel);

                break;

            case CommonModels.ActionType.EditEmployee:

                EditEmployee editEmployee = new EditEmployee();
                outputModel = editEmployee.Edit(inputModel);

                break;

            case CommonModels.ActionType.DeleteEmployee:

                DeleteEmployee deleteEmployee = new DeleteEmployee();
                outputModel = deleteEmployee.Delete(inputModel);

                break;

            case CommonModels.ActionType.GetEmployee:

                GetEmployeeList getEmployeeList = new GetEmployeeList();
                outputModel = getEmployeeList.Get(inputModel);

                break;


            case CommonModels.ActionType.AddDept:

                AddDepatment addDepatment = new AddDepatment();
                outputModel = addDepatment.Add(inputModel);

                break;

            case CommonModels.ActionType.EditDept:

                EditDepatment editDepatment = new EditDepatment();
                outputModel = editDepatment.Edit(inputModel);

                break;

            case CommonModels.ActionType.DeleteDept:

                DeleteDepatment deleteDepatment = new DeleteDepatment();
                outputModel = deleteDepatment.Delete(inputModel);

                break;

            case CommonModels.ActionType.GetDept:

                GetDepatmentList GetDepatmentList = new GetDepatmentList();
                outputModel = GetDepatmentList.Get(inputModel);

                break;

            case CommonModels.ActionType.Login:

                LoginAction loginAction = new LoginAction();
                outputModel = loginAction.login(inputModel);

                break;

            case CommonModels.ActionType.ForgotPassword:

                LoginGet LoginGet = new LoginGet();
                outputModel = LoginGet.Getlogin(inputModel);

                break;



            default:
                outputModel = new OuputModel()
                {
                };
                break;
            }

            return(await Task.FromResult(outputModel));
        }