コード例 #1
0
        /// <summary>
        /// Add photos to employee
        /// </summary>
        /// <param name="employeeId">Employee identifier</param>
        /// <param name="photos">Employee photo</param>
        public Model.EmployeePhotoExecutionResults EmployeePhotosAdd(long employeeId, Model.EmployeePhoto[] photos)
        {
            UpdateSessionCulture();
            using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, RaiseLog))
                try
                {
                    var emp = EmployeeGet(employeeId);
                    if (emp.Exception != null)
                        throw emp.Exception;

                    using (var rep = GetNewRepository(logSession))
                    {
                        var empphs = photos.Select(p => new Repository.Model.EmployeePhoto()
                        {
                            EmployeeId = employeeId,
                            FileId = p.FileId,
                        });
                        rep.AddRange(empphs);
                    }

                    return EmployeePhotosGet(employeeId);
                }
                catch (Exception ex)
                {
                    ex.Data.Add(nameof(employeeId), employeeId);
                    ex.Data.Add(nameof(photos), photos.Concat(p => p.ToString(),", "));
                    logSession.Enabled = true;
                    logSession.Add(ex);
                    return new EmployeePhotoExecutionResults(ex);
                }
        }
コード例 #2
0
 /// <summary>
 /// Add photos to employee
 /// </summary>
 /// <param name="employeeId">Employee identifier</param>
 /// <param name="photos">Employee photo</param>
 public Model.EmployeePhotoExecutionResults RESTEmployeePhotosAdd(string employeeId, Model.EmployeePhoto[] photos)
 {
     UpdateSessionCulture();
     using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, RaiseLog))
         try
         {
             var id = LongFromString(employeeId);
             return EmployeePhotosAdd(id, photos);
         }
         catch (Exception ex)
         {
             ex.Data.Add(nameof(employeeId), employeeId);
             ex.Data.Add(nameof(photos), photos.Concat(p => p.ToString(), ", "));
             logSession.Enabled = true;
             logSession.Add(ex);
             return new EmployeePhotoExecutionResults(ex);
         }
 }