public async Task <IHttpActionResult> PutTrainerDetail(string id, TrainerDetail trainerDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != trainerDetail.TrDetailId) { return(BadRequest()); } db.Entry(trainerDetail).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrainerDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostTrainerDetail(TrainerDetail trainerDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TrainerDetails.Add(trainerDetail); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (TrainerDetailExists(trainerDetail.TrDetailId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = trainerDetail.TrDetailId }, trainerDetail)); }
public ActionResult SaveAddTrainer(TrainerDetail registerDetails) { //We check if the model state is valid or not. We have used DataAnnotation attributes. //If any form value fails the DataAnnotation validation the model state becomes invalid. if (ModelState.IsValid) { //create database context using Entity framework using (var databaseContext = new Attendance_MarkingEntities()) { //If the model state is valid i.e. the form values passed the validation then we are storing the User's details in DB. TrainerDetail reglog = new TrainerDetail(); //Save all details in RegitserUser object reglog.TrainerId = registerDetails.TrainerId; reglog.TrainerName = registerDetails.TrainerName; reglog.ContactNumber = registerDetails.ContactNumber; reglog.Skills = registerDetails.Skills; reglog.Email = registerDetails.Email; //Calling the SaveDetails method which saves the details. databaseContext.TrainerDetails.Add(reglog); databaseContext.SaveChanges(); } ViewBag.Message = " Details Sucessfully Saved"; //return View("Register"); return(View("AddTrainer")); } else { //If the validation fails, we are returning the model object with errors to the view, which will display the error messages. return(View("AddTrainer", registerDetails)); } }
public override global::System.Data.DataSet Clone() { TrainerDetail cln = ((TrainerDetail)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public async Task <IHttpActionResult> GetTrainerDetail(string id) { TrainerDetail trainerDetail = await db.TrainerDetails.FindAsync(id); if (trainerDetail == null) { return(NotFound()); } return(Ok(trainerDetail)); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { TrainerDetail ds = new TrainerDetail(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public async Task <IHttpActionResult> DeleteTrainerDetail(string id) { TrainerDetail trainerDetail = await db.TrainerDetails.FindAsync(id); if (trainerDetail == null) { return(NotFound()); } db.TrainerDetails.Remove(trainerDetail); await db.SaveChangesAsync(); return(Ok(trainerDetail)); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); TrainerDetail ds = new TrainerDetail(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "TrainerDetailDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public async Task <IHttpActionResult> PostTrainerPersonalDetails(TrainerPersonalDTO trainerPersonalDetails) { var user = await db.Users.Where(x => x.Email == trainerPersonalDetails.email).SingleOrDefaultAsync(); if (user == null) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "User Not Found, Please perform SignUp/Register"))); } //Check if trainer application detail exist-In case he/she has partially filled the apllictaion form var trainerDb = db.Trainers.SingleOrDefault(x => x.UserID == user.Id); if (trainerDb != null) { var CommDetail = db.CommonDetails.Where(x => x.ID == trainerDb.CommonDetailID).SingleOrDefault(); CommDetail.Address = trainerPersonalDetails.address; CommDetail.state = trainerPersonalDetails.state; CommDetail.City = trainerPersonalDetails.City; //CommDetail.DOB = DateTime.ParseExact(trainerPersonalDetails.dob, "dd/MM/YYYY", CultureInfo.InvariantCulture); CommDetail.DOB = Convert.ToDateTime(trainerPersonalDetails.dob); CommDetail.PINCode = trainerPersonalDetails.PINCode; db.Entry(CommDetail).State = EntityState.Modified; try { var result = await db.SaveChangesAsync(); trainerPersonalDetails.CommonDetailID = CommDetail.ID; trainerPersonalDetails.TrainerId = trainerDb.TrainerId; return(Ok(trainerPersonalDetails)); } catch (Exception ex) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message))); } } else { CommonDetail commonDetailObj = new CommonDetail() { ID = Guid.NewGuid().ToString(), Address = trainerPersonalDetails.address, AcademicYear = null, DOB = Convert.ToDateTime(trainerPersonalDetails.dob), Department = String.Empty, Grade = null, Photo = null, HighestQualification = String.Empty, state = trainerPersonalDetails.state, City = trainerPersonalDetails.City, PINCode = trainerPersonalDetails.PINCode }; Trainer trainerObj = new Trainer() { TrainerId = Guid.NewGuid().ToString(), UserID = user.Id, //FirstName = null,//TODO: Need to remove since user table already contain firstname //LastName = null,//TODO: Need to remove since user table already contain lastname CommonDetailID = commonDetailObj.ID, TypeId = null, RatingId = null, StatusId = null, IsVerified = false }; TrainerDetail trainerDetailObj = new TrainerDetail() { TrDetailId = Guid.NewGuid().ToString(), TrainerId = trainerObj.TrainerId, Experience = null, Companies = null, SkillSet = null, TeachingExperience = null, TeachingReason = null, SocialMediaId = null }; using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { db.CommonDetails.Add(commonDetailObj); db.Trainers.Add(trainerObj); db.TrainerDetails.Add(trainerDetailObj); var result = await db.SaveChangesAsync(); transaction.Commit(); trainerPersonalDetails.CommonDetailID = commonDetailObj.ID; trainerPersonalDetails.TrainerId = trainerObj.TrainerId; return(Ok(trainerPersonalDetails)); } catch (Exception ex) { transaction.Rollback(); return(InternalServerError(new ApplicationException("Something went wrong in this request. internal exception: " + ex.Message))); } } } }
public async Task <IHttpActionResult> PostTrainer(TrainerDTO trainer) { var user = await db.Users.Where(x => x.Email == trainer.email).SingleOrDefaultAsync(); if (user == null) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "User Not Found, Please perform SignUp/Register"))); } //Check if trainer application detail exist-In case he/she has partially filled the apllictaion form var trainerDb = db.Trainers.SingleOrDefault(x => x.UserID == user.Id); //if (trainerDb!=null) //{ // trainerDb. //} //else //{ //} CommonDetail commonDetailObj = new CommonDetail() { ID = Guid.NewGuid().ToString(), Address = trainer.address, AcademicYear = Convert.ToDateTime(trainer.academicYear), DOB = Convert.ToDateTime(trainer.dob), Department = trainer.department, Grade = null, Photo = null, HighestQualification = trainer.highestQualification, }; Trainer trainerObj = new Trainer() { TrainerId = Guid.NewGuid().ToString(), UserID = user.Id, //FirstName = trainer.firstName, //LastName = trainer.lastName, CommonDetailID = commonDetailObj.ID, TypeId = null, RatingId = null, StatusId = null, IsVerified = false }; TrainerDetail trainerDetailObj = new TrainerDetail() { TrDetailId = Guid.NewGuid().ToString(), TrainerId = trainerObj.TrainerId, Experience = trainer.industrialExp, Companies = trainer.companies, SkillSet = trainer.skillSet, TeachingExperience = trainer.teachingExp, TeachingReason = null, SocialMediaId = trainer.socialMediaLink }; try { db.CommonDetails.Add(commonDetailObj); db.Trainers.Add(trainerObj); db.TrainerDetails.Add(trainerDetailObj); var result = await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = trainerObj.TrainerId }, trainerObj)); } catch (DbUpdateException ex) { throw ex; } catch (Exception ex) { throw ex; } }