public async Task <IHttpActionResult> Add(PersonApp instance) { var result = await PersonHandler.Add(instance); var resultModel = await PersonHandler.Get(result.Value); return(CreatedAtRoute("Default", new { controller = "Person", action = "Get", id = result.Value }, resultModel.Value)); }
// POST: api/Person public HttpResponseMessage Post([FromBody] Person value) { PersonApp pa = new PersonApp(); int id = pa.SavePerson(value); value.idPerson = id; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created); response.Headers.Location = new Uri(Request.RequestUri, string.Format("person/{0}", id)); return(response); }
// GET: api/Person/5 public Person Get(int idPerson) { PersonApp pa = new PersonApp(); Person person = pa.GetPerson(idPerson); //person.idPerson = id; //person.firstName = "Bac"; //person.lastName = "Le Phuoc"; //person.dateOfBirth = "03/02/1996"; return(person); }
public async Task <BusinessResult <long> > Add(PersonApp instance) { var domainModel = Mapper.Map <Person>(instance); var domainResult = await PersonService.Add(domainModel); var result = new BusinessResult <long>() { Success = domainResult > 0, Value = domainResult }; return(result); }
// DELETE: api/Person/5 public HttpResponseMessage Delete(int id) { PersonApp pa = new PersonApp(); bool recordExisted = false; recordExisted = pa.DeletePerson(id); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }
// PUT: api/Person/5 public HttpResponseMessage Put(int id, [FromBody] Person value) { PersonApp pa = new PersonApp(); bool recordExisted = false; recordExisted = pa.UpdatePerson(id, value); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.OK); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }
public void Test01() { PersonApp app = new PersonApp(_session); PersonCreationRequest personCreationRequest = new PersonCreationRequest { Name = "xxx", ZipCode = "xxx", EMail = "xxx", Content = "xxx" }; app.Execute(personCreationRequest); personCreationRequest.ZipCode = "xxxxxx"; app.Execute(personCreationRequest); PersonUpdateRequest personUpdateRequest = new PersonUpdateRequest { Name = "xxx", City = "xxxx", Content = "xxxx" }; app.Execute(personUpdateRequest); PersonViewRequest personViewRequest = new PersonViewRequest(); var list = app.Execute(personViewRequest); var result = list.FirstOrDefault(); PersonDeletionRequest personDeletionRequest = new PersonDeletionRequest { PersonId = "1" }; app.Execute(personDeletionRequest); }
static void Main(string[] args) { PersonApp runningapp = new PersonApp(); runningapp.TheApp(); }
// GET: api/Person //public IEnumerable<string> Get() //{ // return new string[] { "Person1", "Person2" }; //} public ArrayList Get() { PersonApp pa = new PersonApp(); return(pa.GetPerson()); }
//TotalOs = (c.OsContractorProducts.Any() ? c.OsContractorProducts.Sum(d => d.ValueTotal) : 0) + // (c.OsContractorServices.Any() ? c.OsContractorServices.Sum(d => d.ValueService) : 0) + // (c.OsProducts.Any() ? c.OsProducts.Sum(d => d.ValueTotal) : 0) + // (c.OsServices.Any() ? c.OsServices.Sum(d => d.ValueService) : 0) + // (c.OsServices.Any() ? c.OsServices.Sum(d => d.ValueService) : 0) public object QueryCapaOrdemServico(Expression <Func <OrderOfService, bool> > expression) { var vehicle = new OsVehicleApp(_connection); var OsContractorServices = new OsContractorServiceApp(_connection); var Contractor = new PersonApp(_connection); var osServiceapp = new OsServiceApp(_connection); var osProdutos = new OsProductApp(_connection); var osService = _OrderOfServiceApp.Search(expression) .Include(c => c.OsVehicles) .Include(c => c.OsContractorServices) .Include(c => c.Contractor) .Include(c => c.OsProducts) .Include(c => c.OsServices); var result = (from objeto in osService select new { objeto.Id, objeto.NumberOs, DateOs = objeto.DateOfIssure, TimeOs = objeto.DateOfIssure, objeto.DeadName, objeto.ResponsibleName, objeto.PlaceOfDead, objeto.BurialPlace, objeto.WakeLocation, objeto.Phone1, objeto.Phone2, PlanDescription = objeto.Plan.Description, objeto.Sinister, DateOfDead = objeto.DateOfDead, BurialDate = objeto.BurialDate, BurialTime = objeto.BurialTime, objeto.GeneralInformation, objeto.Contractor.PersonName, objeto.Contractor.Cnpj, ContractorId = objeto.Contractor.Id, CodigoContratada = objeto.Contractor.Id, ContractorName = objeto.Contractor.PersonName, ComercialPhone = objeto.Contractor.CommercialPhone, objeto.Contractor.CellPhone, ValueTotalServices = ( (objeto.OsServices.Any() ? objeto.OsServices.Sum(c => c.ValueService) : 0) + (objeto.OsProducts.Any() ? objeto.OsProducts.Sum(c => c.ValueTotal) : 0) + (objeto.OsVehicles.Any() ? objeto.OsVehicles.Sum(C => C.ValueService) : 0) + (objeto.OsContractorServices.Any() ? objeto.OsContractorServices.Sum(c => c.ValueService) : 0) ), objeto.Contractor.Street, objeto.Contractor.Neighborhood, objeto.Contractor.City.CityName, StateInitials = objeto.Contractor.State.Initials, objeto.Contractor.ZipCode } ); //var resultLinq = (from objeto in osService // join t2 in vehicle.Search() on objeto.Id equals t2.OrderOfServiceId into t6 // join t3 in OsContractorServices.Search() on objeto.Id equals t3.OrderOfServiceId into t7 // join t5 in Contractor.Search() on objeto.Contractor.Id equals t5.Id into t9 // join t10 in osProdutos.Search() on objeto.Id equals t10.OrderOfServiceId into t11 // join t12 in osServiceapp.Search() on objeto.Id equals t12.OrderOfServiceId into t13 // from t2 in t6.DefaultIfEmpty() // from t3 in t7.DefaultIfEmpty() // from t5 in t9.DefaultIfEmpty() // from t10 in t11.DefaultIfEmpty() // from t12 in t13.DefaultIfEmpty() // select new // { // objeto.Id, // objeto.NumberOs, // DateOs = objeto.DateOfIssure, // TimeOs = objeto.DateOfIssure, // objeto.DeadName, // objeto.ResponsibleName, // objeto.PlaceOfDead, // objeto.BurialPlace, // objeto.WakeLocation, // objeto.Phone1, // objeto.Phone2, // PlanDescription = objeto.Plan.Description, // objeto.Sinister, // DateOfDead = objeto.DateOfDead, // BurialDate = objeto.BurialDate, // BurialTime = objeto.BurialTime, // objeto.GeneralInformation, // objeto.Contractor.PersonName, // objeto.Contractor.Cnpj, // ContractorId = objeto.Contractor.Id, // t2.Drive.DriveName, // t2.VehiclePlate.Plate, // ServiceDescription = t2.Service.Description, // CodigoContratada = t3.Contractor.Id, // ContractorName = t3.Contractor.PersonName, // ComercialPhone = t3.Contractor.CommercialPhone, // t3.Contractor.CellPhone, // ValueTotalServices = ( // (objeto.OsServices.Any() ? objeto.OsServices.Sum(c => c.ValueService) : 0) + // (objeto.OsProducts.Any() ? objeto.OsProducts.Sum(c => c.ValueTotal) : 0) + // (objeto.OsVehicles.Any() ? objeto.OsVehicles.Sum(C => C.ValueService) : 0) + // (objeto.OsContractorServices.Any() ? objeto.OsContractorServices.Sum(c => c.ValueService) : 0) // ), // t3.Contractor.Street, // t3.Contractor.Neighborhood, // t3.Contractor.City.CityName, // StateInitials = t3.Contractor.State.Initials, // t3.Contractor.ZipCode // }); return(result.ToList()); }
public PersonController(IFactoryConnection connection) { _connection = connection; _PersonApp = new PersonApp(connection); }
public Task <bool> Update(PersonApp instance) { throw new NotImplementedException(); }