示例#1
0
        public int Insert(Department dep)
        {
            try
            {
                // Execute the DAL code
                var result = _departmentDbContext.Create(
                    new MongoDB_Department
                {
                    DeptId   = dep.Id,
                    Name     = dep.Name,
                    Location = dep.Location
                });


                // Some logs
                _loggerService.WriteLog($"Insert Department succeeded. ObjectId: {result.Id.ToString()}", LOG.Info);


                // Return the execution result
                return(0);
            }
            catch (Exception ex)
            {
                _loggerService.WriteLog($"Insert Department failed. Exception: {ex.Message}", LOG.Fatal);

                return(-1);
            }
        }