TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ramco Ramco
437
3.4k
541.9k
Post Api with few fields
Feb 25 2021 4:28 PM
Hi
I have below Api but i want only 3 values ID,Name,DepartmentId to be passed in Body to this Api with Encrytion
How it can be done.
[HttpPost]
[ResponseType(typeof(Employee))]
public HttpResponseMessage PostEmployee([FromBody]Employee employee)
{
try
{
db.Employees.Add(employee);
db.SaveChanges();
var message = Request.CreateResponse(HttpStatusCode.Created, employee);
message.Headers.Location = new Uri(Request.RequestUri + employee.ID.ToString());
return message;
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
}
}
-------------------------------------
public partial class Employee
{
public int ID { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string Gender { get; set; }
public Nullable<int> Salary { get; set; }
public Nullable<int> DepartmentId { get; set; }
public string Active { get; set; }
public Nullable<System.DateTime> CreatedOn { get; set; }
public Nullable<System.DateTime> UpdatedOn { get; set; }
//public Department Department { get; set; }
public virtual Department Department { get; set; }
}
Thanks
Reply
Answers (
3
)
Delete Api not working
Asp.net mvc datepicker