예제 #1
0
        // POST: api/Person
        public ResultPerson Post([FromBody] Person newPerson)
        {//create
            ResultPerson resultPerson = new ResultPerson();

            resultPerson = repositoryPerson.addPerson(newPerson);
            return(resultPerson);
        }
예제 #2
0
        // GET: api/Person/5
        public ResultPerson Get(int person_id)
        {
            ResultPerson resultPerson = new ResultPerson();

            resultPerson = repositoryPerson.getPerson(person_id);
            return(resultPerson);
        }
예제 #3
0
        public ResultPerson getPerson(int person_id)
        {
            get_person_Result pers;
            ResultPerson      resultPerson = new ResultPerson();
            Person            searchedPerson;

            FinflowEntities fe = new FinflowEntities();

            var dataResultStoredProcedure = fe.get_person(person_id).GetEnumerator();

            if (dataResultStoredProcedure.MoveNext())
            {
                pers = dataResultStoredProcedure.Current;

                if (pers != null)
                {
                    searchedPerson             = new Person();
                    searchedPerson.person_id   = pers.person_id;
                    searchedPerson.Name        = pers.Name;
                    searchedPerson.Surname     = pers.Surname;
                    searchedPerson.DateOfBirth = pers.DateOfBirth;

                    resultPerson.person = searchedPerson;
                    resultPerson.code   = 0;
                }
            }
            else
            {
                resultPerson.code  = -1;
                resultPerson.error = "Запись не найдена.";
            }

            return(resultPerson);
        }
예제 #4
0
        public Result deletePerson(int _person_id)
        {
            ResultPerson    resultPerson = new ResultPerson();
            int             code         = 0;
            string          str_result   = "";
            FinflowEntities ge           = new FinflowEntities();

            ge.iud_person(3,
                          new ObjectParameter("person_id", _person_id),
                          null,
                          null,
                          null,
                          new ObjectParameter("code", code),
                          new ObjectParameter("str_result", str_result));

            if (code < 0)
            {
                resultPerson.code  = -1;
                resultPerson.error = str_result;
            }
            else
            {
                resultPerson.code  = 0;
                resultPerson.error = "ok";
            }

            return(resultPerson);
        }
예제 #5
0
        public Result updatePerson(Person modifiedPerson)
        {
            ResultPerson    resultPerson = new ResultPerson();
            int             code         = 0;
            string          str_result   = "";
            FinflowEntities ge           = new FinflowEntities();

            ge.iud_person(2,
                          new ObjectParameter("person_id", modifiedPerson.person_id),
                          modifiedPerson.Name,
                          modifiedPerson.Surname,
                          modifiedPerson.DateOfBirth,
                          new ObjectParameter("code", code),
                          new ObjectParameter("str_result", str_result));

            if (code < 0)
            {
                resultPerson.code  = -1;
                resultPerson.error = str_result;
            }
            else
            {
                resultPerson.code  = 0;
                resultPerson.error = "ok";
            }

            return(resultPerson);
        }
예제 #6
0
        public ResultPerson addPerson(Person newPerson)
        {
            ResultPerson    resultPerson = new ResultPerson();
            int             code         = 0;
            string          str_result   = "";
            FinflowEntities ge           = new FinflowEntities();

            ObjectParameter sp_objectParam_person_id  = new ObjectParameter("person_id", newPerson.person_id);
            ObjectParameter sp_objectParam_code       = new ObjectParameter("code", code);
            ObjectParameter sp_objectParam_str_result = new ObjectParameter("str_result", code);

            ge.iud_person(1,
                          sp_objectParam_person_id,
                          newPerson.Name,
                          newPerson.Surname,
                          newPerson.DateOfBirth,
                          sp_objectParam_code,
                          sp_objectParam_str_result);

            code       = Convert.ToInt32(sp_objectParam_code.Value);
            str_result = Convert.ToString(sp_objectParam_str_result.Value);

            if (code < 0)
            {
                resultPerson.code  = -1;
                resultPerson.error = str_result;
            }
            else
            {
                resultPerson.code   = 0;
                resultPerson.error  = "";
                newPerson.person_id = Convert.ToInt32(sp_objectParam_person_id.Value);
            }

            return(resultPerson);
        }