示例#1
0
        public async Task Save(IPersonEntity person)
        {
            var data = JsonConvert.SerializeObject(person);

            HttpContent         httpContent = new StringContent(data, Encoding.UTF8, "application/json");
            HttpResponseMessage response;

            // Update or Create?
            if (person.ID > 0)
            {
                response = await _httpClient.PutAsync("api/Person", httpContent);
            }
            else
            {
                response = await _httpClient.PostAsync("api/Person", httpContent);
            }

            if (response.IsSuccessStatusCode)
            {
                _logger.Write($"Person ID {person.ID} was successfully updated", enLogType.Info);
            }
            else
            {
                _logger.Write($"Person ID {person.ID} failed to be updated: {response.ReasonPhrase}", enLogType.Error);
            }
        }
示例#2
0
 public Person(IPersonEntity entity)
 {
     Id          = entity.Id;
     FirstName   = entity.FirstName;
     LastName    = entity.LastName;
     DateOfBirth = entity.DateOfBirth;
 }
        public DataTable InsertPerson(string userRole, string roleData, string userLogin, IPersonEntity person)
        {
            //ConnectDB("ConnectionString");
            //string queryString = "Insert into Person([person_type_ref], [title], [firstname], [lastname], [emailprimary], [emailalternate], [fax], [phoneprimary], [phonehome], [phonemobile], [phonework], [phoneemergency], [companyname], [position], [description]) values ('" +
            //        person.PersonType + "','" +
            //          person.PersonTitle + "','" +
            //          person.PersonFirstName + "','" +
            //          person.PersonLastName + "','" +
            //          person.PersonEmailPrimary + "','" +
            //          person.PersonEmailAlternate + "','" +
            //          person.PersonFax + "','" +
            //          person.PersonPhonePrimary + "','" +
            //          person.PersonPhoneHome + "','" +
            //          person.PersonPhoneMobile + "','" +
            //          person.PersonPhoneWork + "','" +
            //          person.PersonPhoneEmergency + "','" +
            //          person.PersonCompanyName + "','" +
            //          person.PersonPosition + "','" +
            //          person.PersonDescription + "')";

            //SqlCommand sqlcmd = new SqlCommand(queryString, Connection);

            //sqlcmd.Connection.Open();
            //sqlcmd.ExecuteNonQuery();
            //sqlcmd.Connection.Close();

            DB obj = new DB();

            String storedProcName = "[usp_InsertPerson]";

            //List of parameter required
            SqlParameter[] param = {
                                        new SqlParameter("@UserRole", userRole),
                                        new SqlParameter("@RoleData", roleData),
                                        new SqlParameter("@UserLogin", userLogin),
                                        new SqlParameter("@PersonType", person.PersonType),
                                        new SqlParameter("@PersonTitle", person.PersonTitle),
                                        new SqlParameter("@PersonFirstName", person.PersonFirstName),
                                        new SqlParameter("@PersonLastName", person.PersonLastName),
                                        new SqlParameter("@PersonEmailPrimary", person.PersonEmailPrimary),
                                        new SqlParameter("@PersonEmailAlternate", person.PersonEmailAlternate),
                                        new SqlParameter("@PersonFax", person.PersonFax),
                                        new SqlParameter("@PersonPhonePrimary", person.PersonPhonePrimary),
                                        new SqlParameter("@PersonPhoneHome", person.PersonPhoneHome),
                                        new SqlParameter("@PersonPhoneMobile", person.PersonPhoneMobile),
                                        new SqlParameter("@PersonPhoneWork", person.PersonPhoneWork),
                                        new SqlParameter("@PersonPhoneEmergency", person.PersonPhoneEmergency),
                                        new SqlParameter("@PersonCompanyName", person.PersonCompanyName),
                                        new SqlParameter("@PersonPosition", person.PersonPosition),
                                        new SqlParameter("@PersonDescription", person.PersonDescription),
                                        new SqlParameter("@IsActive", person.PersonIsActive)
                                    };

            DataTable dt = obj.getSPRecords("ConnectionString", storedProcName, param);

            return dt;
        }
示例#4
0
        /// <summary>
        /// Create a new person. Normally SPROC time and we would return the ID - not sure
        /// if SQLite supports peeking identity columns, and the day is drawing
        /// to a close.
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        public int CreatePerson(IPersonEntity person)
        {
            string sql   = "INSERT INTO Person (FirstName, LastName, Age) VALUES (@FirstName, @LastName, @Age) ";
            var    parms = new List <SQLiteParameter>();

            parms.Add(new SQLiteParameter("@FirstName", person.FirstName));
            parms.Add(new SQLiteParameter("@LastName", person.LastName));
            parms.Add(new SQLiteParameter("@Age", person.Age));
            ExecuteNonQuery(sql, parms);
            return(1);
        }
        public DataTable ApprovePerson(string userRole, string roleData, string userLogin, IPersonEntity person)
        {
            DB obj = new DB();

            String storedProcName = "[usp_ApprovePerson]";

            //List of parameter required
            SqlParameter[] param = {
                                        new SqlParameter("@UserRole", userRole),
                                        new SqlParameter("@RoleData", roleData),
                                        new SqlParameter("@UserLogin", userLogin),
                                        new SqlParameter("@PersonID", person.PersonID),
                                        new SqlParameter("@IsActive", person.PersonIsActive)
                                    };

            DataTable dt = obj.getSPRecords("ConnectionString", storedProcName, param);

            return dt;
        }
示例#6
0
 /// <summary>
 /// Returns a PersonEntity, without ID, as a concatenated
 /// string to allow shallow comparison.
 /// </summary>
 /// <param name="person"></param>
 /// <returns></returns>
 private string GetPersonString(IPersonEntity person)
 {
     return($"{person.FirstName}|{person.LastName}|{person.Age}");
 }
 public IPersonEntity Save(IPersonEntity person)
 {
     throw new NotImplementedException();
 }
示例#8
0
 public int CreatePerson(IPersonEntity person)
 {
     throw new NotImplementedException();
 }
示例#9
0
 public int CreatePerson(IPersonEntity person)
 {
     return(1);
 }
        public DataTable UpdatePerson(string userRole, string roleData, string userLogin, IPersonEntity person)
        {
            DB obj = new DB();

            String storedProcName = "[usp_UpdatePerson]";

            //List of parameter required
            SqlParameter[] param = {
                                        new SqlParameter("@UserRole", userRole),
                                        new SqlParameter("@RoleData", roleData),
                                        new SqlParameter("@UserLogin", userLogin),
                                        new SqlParameter("@PersonID", person.PersonID),
                                        //new SqlParameter("@PersonType", person.PersonType),
                                        //new SqlParameter("@PersonTitle", person.PersonTitle),
                                        new SqlParameter("@PersonFirstName", person.PersonFirstName),
                                        new SqlParameter("@PersonLastName", person.PersonLastName),
                                        //new SqlParameter("@PersonEmailPrimary", person.PersonEmailPrimary),
                                        //new SqlParameter("@PersonEmailAlternate", person.PersonEmailAlternate),
                                        //new SqlParameter("@PersonFax", person.PersonFax),
                                        new SqlParameter("@PersonPhonePrimary", person.PersonPhonePrimary),
                                        //new SqlParameter("@PersonPhoneHome", person.PersonPhoneHome),
                                        new SqlParameter("@PersonPhoneMobile", person.PersonPhoneMobile),
                                        //new SqlParameter("@PersonPhoneWork", person.PersonPhoneWork),
                                        //new SqlParameter("@PersonPhoneEmergency", person.PersonPhoneEmergency),
                                        //new SqlParameter("@PersonCompanyName", person.PersonCompanyName),
                                        //new SqlParameter("@PersonPosition", person.PersonPosition),
                                        //new SqlParameter("@PersonDescription", person.PersonDescription),
                                        //new SqlParameter("@IsActive", person.PersonIsActive)
                                    };

            DataTable dt = obj.getSPRecords("ConnectionString", storedProcName, param);

            return dt;
        }
示例#11
0
 public void Remove(IPersonEntity entity)
 {
 }
示例#12
0
 public void Add(IPersonEntity entity)
 {
 }