Esempio n. 1
0
        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;
     }
 }
Esempio n. 3
0
 //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;
     }
 }
Esempio n. 4
0
 //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;
     }
 }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
 public LookupController(DRSEntities mockEntity)
 {
     _db = mockEntity;
 }
Esempio n. 7
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="LookupController" /> class.
 /// </summary>
 public LookupController()
 {
     _db = new DRSEntities();
 }
Esempio n. 8
0
 /// <summary>
 ///     Initailizes instance for unit testing
 /// </summary>
 /// <param name="mockEntity"></param>
 public ProfileController(DRSEntities mockEntity)
 {
     _db = mockEntity;
 }
Esempio n. 9
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ProfileController" /> class.
 /// </summary>
 public ProfileController()
 {
     _db = new DRSEntities();
 }
Esempio n. 10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="JobTypeController" /> class.
 /// </summary>
 public JobTypeController()
 {
     _db = new DRSEntities();
 }
Esempio n. 11
0
        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));
        }
Esempio n. 12
0
 public RadioStationsService()
 {
     db = new DRSEntities();
 }
Esempio n. 13
0
 public VesselsService()
 {
     db = new DRSEntities();
 }
 public DistressService()
 {
     db = new DRSEntities();
 }
Esempio n. 15
0
 public RegistrationsService()
 {
     db = new DRSEntities();
 }
 public OwnersService()
 {
     db = new DRSEntities();
 }
Esempio n. 17
0
 public LicencesService()
 {
     db = new DRSEntities();
 }
Esempio n. 18
0
 public HomeController()
 {
     db = new DRSEntities();
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes controller for unit testing
 /// </summary>
 /// <param name="mockEntity"></param>
 public JobTypeController(DRSEntities mockEntity)
 {
     _db = mockEntity;
 }