public IHttpActionResult UpdateProfile([FromBody] ProfileDTO incomingProfileDTO) { Log.DebugFormat("ProfileController (UpdateProfile)\n"); if (incomingProfileDTO != null) { var profileToUpdate = Mapper.Map <Profile>(incomingProfileDTO); try { ConfigureGraphDiff(profileToUpdate); _db.SaveChanges(); // Now fetch the updated object to send back using (var responseConn = new DRSEntities()) { var refreshedEntity = responseConn.Profiles.SingleOrDefault(x => x.id == profileToUpdate.id); if (refreshedEntity != null) { Log.DebugFormat("Updating of UpdateProfile was successful.\n"); return(Ok(Mapper.Map <ProfileDTO>(refreshedEntity))); } } } catch (DbUpdateConcurrencyException) { var myError = new Error { Code = "400", Message = "The entity being updated has already been updated by another user...", Data = null }; return(new ErrorResult(myError, Request)); } catch (Exception ex) { Log.DebugFormat( $"Error running UpdateProfile. The reason is as follows: {ex.Message} {ex.StackTrace}"); var myError = new Error { Code = "400", Message = "Error running UpdateProfile", Data = new object[] { ex.Message, ex.StackTrace } }; return(new ErrorResult(myError, Request)); } } Log.DebugFormat("incomingProfileDTO cannot be null"); var myError2 = new Error { Code = "400", Message = "incomingProfileDTO cannot be null", Data = null }; return(new ErrorResult(myError2, Request)); }
//select*method public List <district> getAllDistrictsDB() { try { using (var DRS_db = new DRSEntities()) { return(DRS_db.districts.OrderBy(d => d.district_code).Where(d => d.district_status == 1).OrderBy(d => d.district_code).ToList()); } } catch (Exception) { throw; } }
//select*method public List <registration> getAllRegistrationsDB() { try { using (var DRS_db = new DRSEntities()) { return(DRS_db.registrations.OrderBy(r => r.registration_code).Where(r => r.registration_status == 1).OrderBy(r => r.registration_code).ToList()); } } catch (Exception) { throw; } }
//select*method public List <user> getAllUsersDB() { try { using (var DRS_db = new DRSEntities()) { return(DRS_db.users.OrderBy(u => u.mcs_id).Where(u => u.user_status == 1).ToList()); } } catch (Exception) { throw; } }
public IHttpActionResult PostProfile([FromBody] ProfileDTO profileDTO) { var profileToAdd = Mapper.Map <Profile>(profileDTO); try { _db.Profiles.Add(profileToAdd); _db.SaveChanges(); using (var responseConn = new DRSEntities()) { var refreshedEntity = responseConn.Profiles.SingleOrDefault(x => x.id == profileToAdd.id); if (refreshedEntity != null) { Log.DebugFormat("Profile creation was successful.\n"); return(Ok(Mapper.Map <ProfileDTO>(refreshedEntity))); } } } catch (DbEntityValidationException ee) { return(BadRequest(ee.DbEntityValidationResultToString())); } catch (Exception ex) { Log.DebugFormat( $"Error running CheckPerformersList. The reason is as follows: {ex.Message} {ex.StackTrace}"); var myError = new Error { Code = "400", Message = "Error running CheckPerformersList", Data = new object[] { ex.Message } }; return(new ErrorResult(myError, Request)); } Log.DebugFormat("incomingProfileDTO cannot be null"); var myError2 = new Error { Code = "400", Message = "incomingProfileDTO cannot be null", Data = null }; return(new ErrorResult(myError2, Request)); }
public LookupController(DRSEntities mockEntity) { _db = mockEntity; }
/// <summary> /// Initializes a new instance of the <see cref="LookupController" /> class. /// </summary> public LookupController() { _db = new DRSEntities(); }
/// <summary> /// Initailizes instance for unit testing /// </summary> /// <param name="mockEntity"></param> public ProfileController(DRSEntities mockEntity) { _db = mockEntity; }
/// <summary> /// Initializes a new instance of the <see cref="ProfileController" /> class. /// </summary> public ProfileController() { _db = new DRSEntities(); }
/// <summary> /// Initializes a new instance of the <see cref="JobTypeController" /> class. /// </summary> public JobTypeController() { _db = new DRSEntities(); }
public IHttpActionResult CheckPerformersList(ProfileDTO incomingProfileDTO) { Log.DebugFormat("ProfileController (CheckPerformersList)\n"); if (incomingProfileDTO != null) { var profileToUpdate = Mapper.Map <Profile>(incomingProfileDTO); profileToUpdate.ProfileProfessional.performersListCheckedDate = DateTime.Now; profileToUpdate.ProfileProfessional.performersListCheckedBy = User.Identity.Name; try { // Create a graph of the Profile entity ConfigureGraphDiff(profileToUpdate); _db.SaveChanges(); // Now fetch the updated object to send back using (var responseConn = new DRSEntities()) { var refreshedEntity = responseConn.Profiles.SingleOrDefault(x => x.id == profileToUpdate.id); if (refreshedEntity != null) { Log.DebugFormat("Updating of CheckPerformersList was successful.\n"); return(Ok(Mapper.Map <ProfileDTO>(refreshedEntity))); } } } catch (DbUpdateConcurrencyException) { var myError = new Error { Code = "400", Message = "The entity being updated has already been updated by another user...", Data = null }; return(new ErrorResult(myError, Request)); } catch (Exception ex) { Log.DebugFormat( $"Error running CheckPerformersList. The reason is as follows: {ex.Message} {ex.StackTrace}"); var myError = new Error { Code = "400", Message = "Error running CheckPerformersList", Data = new object[] { ex.Message } }; return(new ErrorResult(myError, Request)); } Log.DebugFormat("Updating of CheckPerformersList was successful.\n"); return(Ok(Mapper.Map <ProfileDTO>(profileToUpdate))); } Log.DebugFormat("incomingProfileDTO cannot be null"); var myError2 = new Error { Code = "400", Message = "incomingProfileDTO cannot be null", Data = null }; return(new ErrorResult(myError2, Request)); }
public RadioStationsService() { db = new DRSEntities(); }
public VesselsService() { db = new DRSEntities(); }
public DistressService() { db = new DRSEntities(); }
public RegistrationsService() { db = new DRSEntities(); }
public OwnersService() { db = new DRSEntities(); }
public LicencesService() { db = new DRSEntities(); }
public HomeController() { db = new DRSEntities(); }
/// <summary> /// Initializes controller for unit testing /// </summary> /// <param name="mockEntity"></param> public JobTypeController(DRSEntities mockEntity) { _db = mockEntity; }