public EntityBase ManagementUpdateEmployee(ManagementTeam.Employee employee)
        {
            //System.Diagnostics.Debugger.Launch();
            var resultEntityBase = new EntityBase();

            try
            {
                using (var connection = new SqlConnection
                                            (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString))
                {
                    var command = new SqlCommand("dbo.umsp_UpdateEmployee", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@employeeId", employee.Id);
                    //command.Parameters.AddWithValue("@name", employee.Name);
                    //command.Parameters.AddWithValue("@surname", employee.Surname);
                    command.Parameters.AddWithValue("@team", employee.Team);
                    command.Parameters.AddWithValue("@role", employee.Role);
                    command.Parameters.AddWithValue("@project", employee.Project);
                    command.Parameters.AddWithValue("@task", employee.Task);

                    connection.Open();
                    command.ExecuteNonQuery();
                }
                resultEntityBase.StatusInfo = "Employee's data was successfully updated";
            }
            catch (SqlException ex)
            {
                resultEntityBase.StatusInfo = ex.ToString() + "ERROR! Couldn't pass data to DB";
            }
            return(resultEntityBase);
        }
예제 #2
0
        /// <summary>
        /// Returns employee with filled in data
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        internal ManagementTeam.Employee GetInfoAboutEmployee(ManagementTeam.Employee employee)
        {
            // Server Url
            string commandUrl = "http://localhost:53654/api/TestWAPIManager/GetTestEmployee";
            // Initializing request
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(commandUrl);

            request.Method      = WebRequestMethods.Http.Post;
            request.ContentType = "application/octet-stream";
            // Binary serialization
            BinaryFormatter bf = new BinaryFormatter();

            using (Stream requestStream = request.GetRequestStream())
            {
                bf.Serialize(requestStream, employee);
                //request.ContentLength = requestStream.Length;
                //requestStream.Write(requestStream, 0, request.ContentLength);
            }

            // Sending request to the server
            WebResponse response = request.GetResponse();

            // Getting response from the server
            using (Stream responseStream = response.GetResponseStream())
            {
                // Desirializing response-stream to expected object type
                ManagementTeam.Employee empl = (ManagementTeam.Employee)bf.Deserialize(responseStream);
                return(empl);
            }
        }
예제 #3
0
        internal ManagementTeam.Employee GetDataAbout(ManagementTeam.Employee employee)
        {
            // Server url
            string commandUrl = "http://localhost:53865/api/dal/GetDataFromDb";
            // Initializing request
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(commandUrl);

            request.Method = WebRequestMethods.Http.Post;
            // Wasn't working, added:
            request.ContentType = "application/octet-stream";
            // Binary serialization
            BinaryFormatter bf = new BinaryFormatter();

            //bf.Serialize(request.GetRequestStream(), employee);
            //request.GetRequestStream();
            using (Stream requestStream = request.GetRequestStream())
            {
                bf.Serialize(requestStream, employee);
            }
            // Sending request to the server
            WebResponse response = request.GetResponse();
            // Getting response from the server
            //using (Stream responseStream = response.GetResponseStream())
            {
                Stream responseStream = response.GetResponseStream();

                var memoryStream = new MemoryStream();
                responseStream.CopyTo(memoryStream);
                memoryStream.Seek(0, SeekOrigin.Begin);
                memoryStream.Position = 0;
                // Desirializing response-stream to expected object type
                //Employee empl = (Employee)bf.Deserialize(responseStream);
                ManagementTeam.Employee empl = (ManagementTeam.Employee)bf.Deserialize(memoryStream);

                responseStream.Close();
                memoryStream.Close();
                return(empl);
            }

            //{
            //    string url = textBox2.Text;
            //    //string commandUrl = url + "name=" + textBox1.Text + "&age=" + textBox3.Text;
            //    string commandUrl = "http://localhost:53865/api/dal/GetDataFromDb";

            //    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(commandUrl);
            //    request.ContentLength = 0;
            //    request.Method = "POST";
            //    WebResponse response = request.GetResponse();
            //    using (Stream stream = response.GetResponseStream())
            //    {
            //        var sr = new StreamReader(stream);
            //        var str = sr.ReadToEnd();
            //        richTextBox1.Text = str;
            //    }
            //}
        }
예제 #4
0
 /// <summary>
 /// Casts DataModel entity to MVC Model entity
 /// </summary>
 /// <param name="employee"></param>
 internal EmployeeManagementModel CastToManagementEmployeeModel(ManagementTeam.Employee employee)
 {
     return(new EmployeeManagementModel()
     {
         Id = employee.Id,
         Name = employee.Name,
         //Surname = employee.Surname,
         Surname = employee.LastName,
         Team = employee.Team,
         Task = employee.Task,
         Project = employee.Project,
         Role = employee.Role
     });
 }
        public string ManagementAddCommonEmployee(ManagementTeam.Employee employee)
        {
            //System.Diagnostics.Debugger.Launch();
            using (var connection = new SqlConnection
                                        (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString))
            {
                var command = new SqlCommand("dbo.umsp_AddEmployee", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@employeeName", employee.Name);
                command.Parameters.AddWithValue("@employeeSurname", employee.Surname);

                connection.Open();
                command.ExecuteNonQuery();
            }
            return("Employee was successfully added");
        }
예제 #6
0
 public EntityBase ManagementUpdateEmployee(ManagementTeam.Employee employee)
 {
     throw new NotImplementedException();
 }