Posts

Showing posts from June, 2019

Test WebService using Postman

Image
1. get token 2. call a method without authen and no parameter input: 3. call a method with an authen token and parameter input: [Authorize]         [HttpPost]         [Route("api/job/saveAddTextJob")]         public HttpResponseMessage SaveAddTextJob([FromBody]MessageModel model)         {  ..... } 4. Call API with File Upload and Job_No:

ASP Net API pass parameter frombody

Image
The action method: 1. Parameter as string public HttpResponseMessage AddText(string jobNo,[FromBody] string text)  {  .... } test action: 2. Parameter as Custom Object public class AddScheduleNote     {         public string JobNo { get; set; }         public string ScheduleNote { get; set; }     }  ................... public HttpResponseMessage UpdateScheduleNote([FromBody] AddScheduleNote note)         {             try             {                 JobSchedule job = db.JobSchedules.Where(r => r.Job_No.Equals(note.JobNo, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();                 if (job == null)                 {                 ...

Update database in Entity Frameword Code first

1. create model (class for table) public class Customer     {         [Key]         public string CustCode { get; set; }         public string Name { get; set; }         public string Address1 { get; set; }   } 2. create DB context:  public class AMWinDBContext: DbContext     {         public AMWinDBContext(): base("AMWinDBContext")         {        }         protected override void OnModelCreating(DbModelBuilder modelBuilder)         {             modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();         }         public virtual DbSet<Customer> Customers { get; set; }         public virtual DbSet<Employee> Employees { get; set; } ...