am trying to post data from angularjs2 to asp.net mvc controller.

The actual issue is that when I am trying with it then

See how am I trying ?

this is the typescript ---

 save(company: Company): Observable<boolean> {     
        let headers = new Headers({ 'Content-Type': 'application/json' });
         this._http.post(this._postUrl, /*JSON.stringify(*/company/*)*/, { headers: headers }) 
            .subscribe(
             (data) => {                 
                console.log('Response');               
                new Observable<true>()
            },
             (err) => { console.log(err); new Observable<false>(); },
            () => console.log('Complete')
            );         

         return new Observable<false>();

          }

onSignUpClicked(message: string): void {
        this._service.save(this.company).subscribe(
           res => console.log(res),
            error => this.errorMessage = <any>error
        );

this is the typescript class:

import { Address } from '../shared/Address';
import { Contact } from '../shared/Contact';

export class Entity {
    Id: string;
    InsertionTime: Date;
    InsertUserId: number;
    IsDeleted: boolean;
    IsLocked: boolean;
    UpdateTime: Date;
    UpdateUserId: number;
}

export class Company extends Entity {  
    Name: string;
    Address: Address;
    Contact: Contact;
    Password: string;
    ConfirmPassword: string;
    UserName: string;
    RegistrationDate: Date;
    IsActive: boolean;
    NextBillingDate: string;
    TransactionLimit: number
}

and C# class

public class Company : Entity
    {       
        public string Name { get; set; }
        public Address Address { get; set; }
        public Contact Contact { get; set; }
        public string Password { get; set; }
        public string UserName { get; set; }
        public Image LogoImage { get; set; }
        public DateTime RegistrationDate { get; set; }
        public DateTime LastUpdated { get; set; }
        public bool IsActive { get; set; }
        public DateTime NextBillingDate { get; set; }
        public Int64 TransactionLimit { get; set; }
    }

 public class Entity : IEntity
    {
        public Entity()
        {
            Id = Guid.NewGuid();
            InsertionTime = DateTime.Now;
            IsDeleted = false;
            IsLocked = false;
        }

        public Guid Id
        {
            get;set;
        }

        public DateTime InsertionTime
        {
            get;set;
        }

        public int InsertUserId
        {
            get; set;
        }

        public bool IsDeleted
        {
            get; set;
        }

        public bool IsLocked
        {
            get; set;
        }

        public DateTime? UpdateTime
        {
            get;set;
        }

        public int? UpdateUserId
        {
            get; set;
        }

    }

any help appreciated

share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.