public static StudentMember Add(string FullName, int Age, string Section, int ClassNumber)
        {
            int           lastId           = container.Value.Max(sM => sM.Id);
            StudentMember newStudentMember = new StudentMember(lastId + 1, FullName, Age, Section, ClassNumber);

            container.Value.Add(newStudentMember);
            return(newStudentMember);
        }
        private async Task <HttpResponseMessage> HttpPut(HttpControllerContext controllerContext) // if Put Request Method
        {
            HttpResponseMessage retVal = null;
            string contentAsString     = await controllerContext.Request.Content.ReadAsStringAsync();

            StudentMember postedStudentMember = await Newtonsoft.Json.JsonConvert.DeserializeObjectAsync <StudentMember>(contentAsString);

            if (StudentMemberRepositories.IsExist(postedStudentMember.FullName))
            {
                retVal = controllerContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Unable to find Student Member with given Id");
            }
            else
            {
                StudentMemberRepositories.Update(postedStudentMember);
                retVal = controllerContext.Request.CreateResponse(HttpStatusCode.OK, postedStudentMember);
            }
            return(retVal);
        }
        private async Task <HttpResponseMessage> HttpPost(HttpControllerContext controllerContext)// if Post Request Method
        {
            HttpResponseMessage retVal = null;
            string contentAsString     = await controllerContext.Request.Content.ReadAsStringAsync();

            StudentMember postedStudentMember = await Newtonsoft.Json.JsonConvert.DeserializeObjectAsync <StudentMember>(contentAsString);

            if (StudentMemberRepositories.IsExist(postedStudentMember.FullName))
            {
                retVal = controllerContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Another Studen member the same Fullnam is already exist.");
            }
            else
            {
                StudentMember studentMember = StudentMemberRepositories.Add(postedStudentMember.FullName, postedStudentMember.Age, postedStudentMember.Section
                                                                            , postedStudentMember.ClassNumber);
                retVal = controllerContext.Request.CreateResponse(HttpStatusCode.OK, studentMember);
            }
            return(retVal);
        }
Esempio n. 4
0
 public StaffMember(StudentMember history, string id)
 {
     this.id             = id;
     this.studentHistory = history;
 }
 public static void Update(StudentMember StudentMember)
 {
     Remove(StudentMember.Id);
     container.Value.Add(StudentMember);
 }
Esempio n. 6
0
 public FacultyMember(StudentMember history, string id) : base(history, id)
 {
 }